Heaps are advanced data structures that are useful for specific use-cases such as sorting and implementing priority queues.
Heaps can be thought of as regular binary trees with two special characteristics.
All the parent node keys must be greater than or equal to their child node keys in max-heaps. So the root node will always contain the largest element in the Heap. If Node A has a child node B, then,
In Min-Heaps, all the parent node keys are less than or equal to their child node keys. So the root node, in this case, will always contain the smallest element present in the Heap. If Node A has a child node B, then:
View all Courses