Convert the H array into a Binary Max-Heap. Provide simulations for each step.
H: {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}
The steps to conversion of array to heap is given below-
Index of root element is at 0 position
Let i is the index of the node in the array
H: {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}
step 1:
step 2:
step 3
step 4
step 5
step 5:
Step 6:
step 7:
Hence the max heap binary tree will be the given binary tree.
Comments
Leave a comment