27 May 2021 - Hadron DaVinci
Create a Max Heap with the following array. [-3, 11, 52, 4, 23, 70, 65, 100]
breadth_first_order = [-3, 11, 52, 4, 23, 70, 65, 100]
h = BinaryTree(breadth_first_order)
After Max Heaped
____100___
/ \
_23 _70
/ \ / \
11 -3 52 65
/
4
Setup Binary Tree with array
Heapifies all descendants of root recursively
Complexity
Time Complexity: N
Space Complexity: N
Setup Binary Tree with a preorder
Traverse tree in reverse-level order and heapify node
Complexity
Time Complexity: N
Space Complexity: N
same as Method 2 but input is an array in breadth-first order