Binary Heap in Data Structure


Heap or Binary Heap is a special case of balanced binary tree data structure. This is complete binary tree structure. So up to l-1 levels it is full, and at l level, all nodes are from left. Here the root-node key is compared with its children and arranged accordingly. If a has child node b then −

key(a) ≥ key(b)

As the value of parent is greater than that of child, this property generates Max Heap. Based on this criteria, a heap can be of two types the Max Heap and the Min Heap.

These are examples of Max and Min Heap respectively −


Updated on: 10-Aug-2020

323 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements