0% completed
Introduction to Heap
Heaps are a tree-based data structure designed for efficient priority management. They are widely used in priority queues, Dijkstra’s shortest path algorithm, heap sort, and scheduling systems. A heap is a special type of binary tree that maintains a specific order between parent and child nodes.
A heap is always a complete binary tree, meaning all levels are fully filled except possibly the last level, which is filled from left to right.
.....
.....
.....
senthil kumar
· 2 years ago
n a binary min heap, every node must be smaller than or equal to its children. The iterative approach only checks and maintains this property for the inserted node and its parent, but it doesn't check the sibling of the inserted node. This could lead to a situation where a node is smaller than one child but larger than the other.
So, while the iterative approach is a valid start, it's not a complete implementation of a binary min heap. The recurrsion approach is a complete and correct implementation.