← Heapify | Heapify Floyd Bottom Up | Heap Sort →
Exit Slides

Summary

floyd_bottom_up heapify builds a binary_heap efficiently. It treats the array as an array_representation of a tree with children at 2i+1 and 2i+2. Starting at the last nonleaf index, it applies sift_down to restore the heap_property up to the root. This constructs a max_heap or min_heap in place. The method is in_place, uses no extra memory, and runs in linear time_complexity O(n). Remember: begin at floor(n/2) - 1, move to index 0, compare, and swap.
Slide 1 / 3