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.
4768 Points
3054 Points
2920 Points
2728 Points
2602 Points
1572 Points
1422 Points
1362 Points
1334 Points
1126 Points
Gatecse