Heap Visualizer — Min Heap, Max Heap & Heapify Animated | Interview Prep Buddy
Back to Visualizers Hub
⛰️

Heap

A heap is a complete binary tree that satisfies the heap property - parent is either >= (max-heap) or <= (min-heap) children.

DATA STRUCTURE PATTERN

Heaps (Priority Queue)1. Min-Heap Insertion (Heapify Up)

🎯 Expected:Heap Array: [5, 25, 10, 40, 35, 15] (Min at Root)
Milestones:
step 1 / 7
Binary Heap Tree & Flat Array Memory Inspector
Active Node Swapping
10
[0]
25
[1]
15
[2]
40
[3]
35
[4]
5
[5]
Underlying Heap Array:parent = ⌊(i-1)/2⌋ | left = 2i+1 | right = 2i+2
10[0]
25[1]
15[2]
40[3]
35[4]
5[5]
Concept Code
1heap.push(val) // Insert at bottom-left position
2while i > 0 and heap[i] < heap[parent(i)]:
3 swap(heap[i], heap[parent(i)])
4 i ← parent(i)
State Variables
insertedVal5
targetIndex5
statusInsert at Bottom-Left
✏️
line 1Line 1: Insert new element 5 at the end of the heap array (index 5). Element 5 is placed as the left child of node 15.