Priority Queue is an extension of the queue with following properties.
1) An element with high priority is dequeued before an element with low priority.
2) If two elements have the same priority, they are served according to their order in the queue.
Below is simple implementation of priority queue.
12 1 14 7 14 12 7 1 ()
Note that the time complexity of delete is O(n) in above code.
- Priority Queue | Set 1 (Introduction)
- Applications of Priority Queue
- Priority queue of pairs in C++ (Ordered by first)
- Does STL priority queue allow duplicate values?
- STL Priority Queue for Structure or Class
- Priority Queue using Linked List
- Priority Queue using doubly linked list
- Why is Binary Heap Preferred over BST for Priority Queue?
- How to implement stack using priority queue or heap?
- Priority Queue in C++ Standard Template Library (STL)
- Stack and Queue in Python using queue Module
- What’s difference between Priority Inversion and Priority Inheritance ?
- Heap queue (or heapq) in Python
- Check if a queue can be sorted into another queue using a stack
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.