Concept Flow - Heap Extract Min or Max Bubble Down
Start: Extract root (min or max)
Replace root with last element
Remove last element from heap
Set current index = 0
Compare current with children
Left child
Find smaller/larger child
If current violates heap property
Swap current with child
Update current index to child's index
Repeat comparison until heap property restored
Done
This flow shows how extracting the root from a heap replaces it with the last element, then moves that element down by swapping with children until the heap property is restored.