Binary Heap


Concept


Heap is a complete and balanced binary tree.

Complete binary tree

All levels except possibly the last are completely full, and the last level has all its nodes to the left side.

Balanced binary tree
mod (Height(left subtree) – Height(right subtree) ) <= 1

Types

1 . Min heap

Each key  < key of its children

Min-binary-heap


2 . Max heap

Each key  > key of its children

Max-binary-heap

No comments:

Post a Comment