Efficiency
- Describe the efficiency of PriorityQueue based sort using Big-Oh notation.
Consider your implementation of Heap.sort
from the previous section. Assume Java's PriorityQueue
is implemented as Binary Heap, hence insertion/removal are .
Exercise Complete the following table. Use Big-Oh notation to asymptotically describe time/space complexities.
Time Complexity | Space Complexity | Input Space | Auxiliary Space | |
---|---|---|---|---|
Heap.sort |
Solution
- We need a PriorityQueue: auxiliary space.
- inserts into PriorityQueue, each , adds up to
- removes from PriorityQueue, each , adds up to
Time Complexity | Space Complexity | Input Space | Auxiliary Space | |
---|---|---|---|---|
Heap.sort |