• Customer Support: admin@thealgorists.com
  • Feedback: We are listening to your every feedback, and taking action to constantly improve your learning experience. If you have any feedback, please use this form: https://thealgorists.com/Feedback.



You definitely need to have a solid understanding of the internals of Heap data structure and different Heap operations as discussed in:
But every time you need a minheap or a maxheap, you may not have to implement it from scratch. If you are using Java, you could use PriorityQueue class in Java to implement minheap and maxheap as shown below.



This is a Premium content.
Please subscribe to Algorithms course to access the code.





  • 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.


This is a Premium content.
Please subscribe to Algorithms course to access the code.





The above content is written by:

Abhishek Dey

Abhishek Dey

A Visionary Software Engineer With A Mission To Empower Every Person & Every Organization On The Planet To Achieve More

Microsoft | University of Florida

View LinkedIn profile


If you have any feedback, please use this form: https://thealgorists.com/Feedback.




Subscribe to Our Youtube Channel

Follow Us On LinkedIn
wave