Heapify
overview
Summary
heapify builds a heap from an array. In a binary_heap, each parent relates to children. For a max_heap, parent >= children; for a min_heap, parent <= children. Standard heapify runs sift_down from the last non-leaf up to the root, in O(n) time. Indexing facts: 0-based uses left=2i+1, right=2i+2; 1-based uses left=2i, right=2i+1. Common ops: insert uses sift_up; delete_root uses sift_down. Result is a valid heap ready for selection and sorting.