| 1 | Insert 8 at end | [10, 15, 30, 40, 50, 100, 40, 8] | 7 (new element) | Start bubble up | Array: [10, 15, 30, 40, 50, 100, 40, 8] |
| 2 | Compare with parent (index 3) | [10, 15, 30, 40, 50, 100, 40, 8] | 7 (8) vs 3 (40) | 8 < 40 → Swap | Swap elements at 7 and 3 |
| 3 | After swap | [10, 15, 30, 8, 50, 100, 40, 40] | 3 (moved 8) | Move pointer to parent index 3 | Array: [10, 15, 30, 8, 50, 100, 40, 40] |
| 4 | Compare with parent (index 1) | [10, 15, 30, 8, 50, 100, 40, 40] | 3 (8) vs 1 (15) | 8 < 15 → Swap | Swap elements at 3 and 1 |
| 5 | After swap | [10, 8, 30, 15, 50, 100, 40, 40] | 1 (moved 8) | Move pointer to parent index 1 | Array: [10, 8, 30, 15, 50, 100, 40, 40] |
| 6 | Compare with parent (index 0) | [10, 8, 30, 15, 50, 100, 40, 40] | 1 (8) vs 0 (10) | 8 < 10 → Swap | Swap elements at 1 and 0 |
| 7 | After swap | [8, 10, 30, 15, 50, 100, 40, 40] | 0 (moved 8) | Pointer at root, stop bubble up | Array: [8, 10, 30, 15, 50, 100, 40, 40] |
| 8 | Bubble up complete | [8, 10, 30, 15, 50, 100, 40, 40] | N/A | Heap property restored | Final heap array |