GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
80 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 (65k points) 35 222 625 | 80 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 (355 points) 1 3 7

Related questions

+1 vote
1 answer
2
asked in DS by srestha Veteran (65k points) 35 222 625 | 119 views
0 votes
0 answers
3
asked in DS by vaishali jhalani Boss (6.5k points) 8 115 247 | 43 views


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23338 Points

  2. Bikram

    17048 Points

  3. Habibkhan

    7912 Points

  4. srestha

    6228 Points

  5. Debashish Deka

    5438 Points

  6. jothee

    4968 Points

  7. Sachin Mittal 1

    4772 Points

  8. joshi_nitish

    4286 Points

  9. sushmita

    3964 Points

  10. Rishi yadav

    3794 Points


Recent Badges

Popular Question makhdoom ghaya
Popular Question junaid ahmad
Notable Question learner_geek
Notable Question jothee
Popular Question jothee
Notable Question Jeffrey Jose
Notable Question air1ankit
Nice Question jothee
Verified Human shaleen25
Popular Question jothee
27,290 questions
35,142 answers
83,920 comments
33,231 users