Inserting in a Heap
Some basics :
Heap is stored in an array representation.
Starting index is considered to be 1. Element at index 0 will be 0.
For an element in index i, its left child will be at index 2i and right child will be at index 2i + 1.
For elements at index > 2, its parent element will be at the floor value of index /2.
Inserting in a Max Heap :
Inserting in a Min Heap :
Creating a Heap from Existing Array :
Last updated