Heap

Document last modified: 
  1. Number each node with the array index it would have if it were stored in an array as a heap.
  2. Reorganize the tree using the Build_Max_Heap algorithm.
  3. Draw the reorganized tree below using the provided unlabeled tree.
Build_Max_Heap (A)
1 heap-size[A] ← length[A]
  forall j; i<j≤length[A];
      A[ j ] ≥ A[Left( j )] && A[ j ] ≥ A[Right( j )] 
2 for i ← ⌊length[A]/2⌋ downto 1 do
3    Max_Heapify (A, i)

 

#1 Solution

 

#3 Solution

 



Solution