We are Permanently Move to vupk.net Please Join us there.

CS301 Assignment No 5 Solution Spring July 2012

 CS301 Assignment No 5 Solution Spring July 2012

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

Solution:-


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

Question # 2:-
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.
Solution:-


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.