Heap Implementation using PriorityQueue in Java
Get startedজয় শ্রী রাম
🕉You definitely need to have a solid understanding of the internals of Heap data structure and different Heap operations as discussed in:
- Heap Fundamentals
- Heap: GetMax() / GetMin(), DeleteMax() / DeleteMin() and Insert()
- Heapify
- Heap Sort
Login to Access Content
- Did you notice how we used Heap to sort an array ? It is one of the many utilities of heap data structure. It is an O(NlogN) operation as discussed inline in the code.
More Application of Priority Queue:
The below simple code implements the following using Priority Queue:
- A doctor sees emergency patients before seeing a non-emergency patients. But if there are more than one emergency patients, the patient with lower id is seen first. Implement this with Priority Queue.
Login to Access Content