Member-only story
Why And When To Use Binary Heaps
2 min readFeb 12, 2019
There are 2 main reasons to use a Binary Heap, which was created by J.W. J. Williams in 1964 for heapsort.
Why Use Binary Heaps ?
- For instant access to the largest value in the case of a Max Heap or the smallest value in the case of a Min Heap. By “instant access” I mean constant time or O(1) for you computer scientists. This just means that we know where the value will be which is in the root of the tree or at the start of the array, depending on which data structure you are using.
- Useful for priority queues or schedulers, where the earliest item is desired. A practical application for this may be prioritizing patients at a hospital to work on with the highest priority
If you would like to learn more about computer science and Algorithm Analysis , you can take my online course here. I also have a course on Udemy.com called Recurrence Relation Made Easy where I help students to understand how to solve recurrence relations and asymptotic terms such as Big-O, Big Omega, and Theta. You can check out my YouTube channel of videos where I…