Answer to Question #159206 in Algorithms for Hasan Khan

Question #159206

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}

1
Expert's answer
2021-01-30T06:38:05-0500

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

  • nodes are related in the array index
  • Left child (2*i+1)
  • Right child (2*i+2)
  • Parent child (i-1)/2

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.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS