Min and Max heaps are complete binary trees with some unique properties.
A Binary Tree is a tree data structure wherein each node has at most two “children.”
A node in the binary tree typically contains the following properties:
A complete Binary Tree is a binary tree in which every level, except possibly the last, is filled.
The root node has the minimum value.
The value of each node is equal to or greater than the value of its parent node.
A complete binary tree.
The root node has the maximum value.
The value of each node is equal to or less than the value of its parent node.
A complete binary tree.
A Min/Max heap is typically represented as an array.
- Arr[0] Returns the root node.
- Arr[(i-1)/2] Returns the parent node.
- Arr[(2*i)+1] Returns the left child node.
- Arr[(2*i)+2] Returns the right child node.
Get Max or Min Element
Remove Max or Min Element
Insert an Element