In the binary tree shown below, which of the following trees is created after conversion into a (max) heap?
There are 4 anwsers to choose :
By definition, a max heap is a complete binary tree in which the value in each internal node is greater than or equal to the values in the children of that node., so a
, c
, d
are all correct, but there is only one correct anwser!
What am i missing here ?
Asked By : f855a864
Answered By : Computer
There is a typo in your options. In option (b) the root should be 16 not 1. The tree thus formed is the correct answer.
To get it from your original tree do this
for i = floor(Array.Length/2) down to the first element: Max-Heapify(Array,i)
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/31872
0 comments:
Post a Comment
Let us know your responses and feedback