Any code of your own that you haven't looked at for six or more months might as well have been written by someone else. Eagleson law

Priority Queue

Language Java | Level Intermediate | Category Data structure | August 30, 2015 3:56 pm

Data structure Description

A priority queue is a data structure with each element has a priority associated with it. The high priority element served before an element with low priority. Priority queue provides extra flexibility over sorting and quick access to the smallest and largest key in the queue.

Priority queue provides more flexibility than a simple sorted array. The priority queue supports insert, find minimum or maximum and delete minimum or maximum element efficiently.

Write a program to implement priority queue.


Unsorted array before sorting from Array: [12, 34, 56, 23, 45, 78, 46]
Unsorted array before sorting from Heap: 78 45 56 12 23 34 46 
Sorted array after sorting from Priority Queue: 78 56 46 45 34 23 12



No comments available!

Please login to add comments.