key value.
Insert(i):Insert an item
ExtractMin:Extract the item with (minimal, maximal) cost.
- Let H be a priority queue containing n elements.
- Let A be an array
- While H is not empty
- Extract the minimum element from H and append it to A
Since H contains n elements, line 3 will execute exactly n times.
Thus line 3 is O(n).
By definition of a priority queue, line 4 is O(log n )
Therefore the a set of n values can be sorted in O(n log n) using a priority queue.