CS301 Assignment No 5 Spring 2012 solution

Consider the following MAX HEAP, represent this heap in the form of an array, start the array index from 1 instead of 0.

 

 

25 23 15 18 12 7 5 10 14 11 6 3 4 2

0       1       2       3       4     5   6     7    8       9       10   11    12      13     14

 

 

Consider the following array, the value on each index of this array represents the node value of a complete binary tree, you are required to create the complete binary tree from this array.

 

 

Hints:

If “i” is an index of a node then “2i”, “2i +1” and “i/2” represent the left child, right child and parent of the this node respectively.

DOWNLOAD SOLUTION HERE
loading...