# Applications of Priority Queue

A Priority Queue is different from a normal queue, because instead of being a “first-in-first-out”, values come out in order by priority. It is an abstract data type that captures the idea of a container whose elements have “priorities” attached to them. An element of highest priority always appears at the front of the queue. If that element is removed, the next highest priority element advances to the front.

A priority queue is typically implemented using Heap data structure.

**Applications:**

Dijkstra’s Shortest Path Algorithm using priority queue: When the graph is stored in the form of adjacency list or matrix, priority queue can be used to extract minimum efficiently when implementing Dijkstra’s algorithm.

Prim’s algorithm: It is used to implement Prim’s Algorithm to store keys of nodes and extract minimum key node at every step.

Data compression : It is used in Huffman codes which is used to compresses data.

**Artificial Intelligence **: A* Search Algorithm : The A* search algorithm finds the shortest path between two vertices of a weighted graph, trying out the most promising routes first. The priority queue (also known as the fringe) is used to keep track of unexplored routes, the one for which a lower bound on the total path length is smallest is given highest priority.

Heap Sort : Heap sort is typically implemented using Heap which is an implementation of Priority Queue.

Operating systems: It is also use in Operating System for load balancing (load balancing on server), interrupt handling.

This article is contributed by **Sahil Rajput**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

## Recommended Posts:

- Priority Queue using Queue and Heapdict module in Python
- Priority Queue in Python
- Priority Queue | Set 1 (Introduction)
- Double ended priority queue
- Priority queue of pairs in C++ (Ordered by first)
- Implementation of Priority Queue in Javascript
- Huffman Coding using Priority Queue
- Priority Queue using Linked List
- Priority Queue of Vectors in C++ STL with Examples
- Priority queue of pairs in C++ with ordering by first and second element
- Implementation of Non-Preemptive Shortest Job First using Priority Queue
- How to implement stack using priority queue or heap?
- Priority Queue in C++ Standard Template Library (STL)
- Priority Queue using doubly linked list
- Why is Binary Heap Preferred over BST for Priority Queue?
- Applications of Queue Data Structure
- Find the K closest points to origin using Priority Queue
- CPU Scheduling in Operating Systems using priority queue with gantt chart
- Stack and Queue in Python using queue Module
- Check if a queue can be sorted into another queue using a stack