| 1 | Extract root (10) | [10, 15, 30, 40, 50, 100, 40] | root points to 10 | ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│ data:10│──→ │ data:15│──→ │ data:30│──→ │ data:40│──→ │ data:50│──→ │ data:100│──→ │ data:40│
│ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:∅ │
└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘
root |
| 2 | Replace root with last element (40) | [40, 15, 30, 40, 50, 100] | root now points to 40 (last element) | ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│ data:40│──→ │ data:15│──→ │ data:30│──→ │ data:40│──→ │ data:50│──→ │ data:100│
│ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:∅ │
└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘
root |
| 3 | Compare root (40) with children (15, 30) | [40, 15, 30, 40, 50, 100] | current = 0, left child = 1, right child = 2 | Current: 40
Left child: 15
Right child: 30 |
| 4 | Swap root with smallest child (15) | [15, 40, 30, 40, 50, 100] | Swap indices 0 and 1, current = 1 | ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│ data:15│──→ │ data:40│──→ │ data:30│──→ │ data:40│──→ │ data:50│──→ │ data:100│
│ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:──┼ │ next:∅ │
└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘
root current |
| 5 | Compare current (40) with children (40, 50) | [15, 40, 30, 40, 50, 100] | current = 1, left child = 3, right child = 4 | Current: 40
Left child: 40
Right child: 50 |
| 6 | No swap needed (40 <= 40 and 50) | [15, 40, 30, 40, 50, 100] | Heap property restored | Heap is valid min-heap now |