Consider a complete Binary Tree ‘T’ with key of root node be ‘P’. It is given that the left and right subtree of ‘P’ satisfies min-heap property. What is the time taken to convert the given tree ‘T’ to a max heap ?
a)O(log N)
b) O(N)
Apply Build_Max_Heap procedure on the tree, which takes O(N) time.
if the question is
Consider a complete Binary Tree ‘T’ with key of root node be ‘P’. It is given that the left and right subtree of ‘P’ satisfies min-heap property. What is the time taken to convert the given tree ‘T’ to a min heap ?
then answer should be log N, rt?
The answer should be O(N) as we need to to heapify all the nodes in botton up fashion.
23338 Points
17048 Points
7912 Points
6228 Points
5438 Points
4968 Points
4772 Points
4286 Points
3964 Points
3794 Points
Gatecse
X->YZ , Y->XZ , ...