Queue and Priority Queue Flashcards
Array Based Implementation
What is the performance of the enqueue method?
Theta 1 (Constant)
Array Based Implementation
What is the performance of the dequeue method?
Theta 1 (Constant)
Array Based Implementation
What is the performance of the peek method?
Theta 1 (Constant)
Array Based Implementation
What is the performance of the size method?
Theta 1 (Constant)
Array Based Implementation
What is the performance of the empty method?
Theta 1 (Constant)
At what end of a list based queue are insertions efficient?
The back
At what end of a list based queue are removals efficient?
The front
List Based Implementation
What is the performance of the enqueue method?
Theta 1 (Constant)
List Based Implementation
What is the performance of the dequeue method?
Theta 1 (Const)
List Based Implementation
What is the performance of the top method?
Theta 1 (Const)
List Based Implementation
What is the performance of the size method?
Theta 1 (Const)
List Based Implementation
What is the performance of the empty method?
Theta 1 (Const)
Which implementation is more expensive in practice?
List based implementation
What is the definition of a min heap?
- It is a full binary tree
- Each child has a value greater than or equal to compared to its parent
How do we add an element to a heap?
- Add an element to the next available space in the array
- Check if the min heap has been violated
- Climb up to the root, making swaps where needed