GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
68 views

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)

asked in DS by Veteran (52.4k points)   | 68 views

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?

@Sreshtha
yes, then answer will be log(n), call min-heapify function on root which takes logn time
thank u :)

1 Answer

+1 vote

The answer should be O(N)  as we need to to heapify all the nodes in botton up fashion.

answered by (305 points)  

Related questions

+1 vote
1 answer
2
asked in DS by srestha Veteran (52.4k points)   | 59 views
0 votes
0 answers
3
asked in DS by vaishali jhalani Boss (6k points)   | 31 views


Top Users Mar 2017
  1. rude

    4768 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2728 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1572 Points

  7. Vignesh Sekar

    1422 Points

  8. Akriti sood

    1362 Points

  9. Bikram

    1334 Points

  10. Sanjay Sharma

    1126 Points

Monthly Topper: Rs. 500 gift card

21,516 questions
26,842 answers
61,138 comments
23,176 users