Each item has a priority, and the dequeue method removes the item that has the highest priority. Basically, high-priority items are handled first.
When we implemented a priority queue with an array or a linked list, the efficiency of some operations is O(n)\text{O}(n)O(n)
ordered array
O(n)
O(1)
ordered list
unordered array
unordered list
Using a binary heap, the runtime of both the deleteMin and insert operations is O(logn)\text{O}(\log n)O(logn)
binary heap
O(log n)
Last updated 1 year ago