Heap

Heap is a type of balanced binary tree data structure in which the root-node key is compared to its offspring and the data is sorted accordingly. If α has child node β then,

key(α) ≥ key(β)

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 −

For Input → 35 33 42 10 14 19 27 44 26 31

Min-Heap − Where the value of the root node is less than or equal to either of its children.

Max Heap Example

Max-Heap − Where the value of the root node is greater than or equal to either of its children.

Max Heap Example

Both trees are constructed using the same input and order of arrival.

0

2 thoughts on “Heap”

  1. Hiya, I am really glad I’ve found this information. Nowadays bloggers publish only about gossips and internet and this is really irritating. A good web site with interesting content, that is what I need. Thank you for keeping this web site, I will be visiting it. Do you do newsletters? Cant find it.

    0

Leave a Comment

Your email address will not be published. Required fields are marked *