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.
5502 Points
4266 Points
3972 Points
3046 Points
2646 Points
2328 Points
2270 Points
2134 Points
1938 Points
1752 Points
Gatecse