edited by
16,190 views
62 votes
62 votes

Consider a complete binary tree where the left and right subtrees of the root are max-heaps. The lower bound for the number of operations to convert the tree to a heap is

  1. $\Omega(\log n)$
  2. $\Omega(n)$
  3. $\Omega(n \log n)$
  4. $\Omega(n^2)$
edited by

4 Answers

Best answer
65 votes
65 votes

Answer is (A).

Here, lower bound imply best algorithm which works for all cases and hence we should consider worst-case.

Max-Heapify(root).

edited by
25 votes
25 votes

now to make it max heap it take only 2 swap and 2 comparision which is nothing but its height.

so logn time needed.

A is asswer

6 votes
6 votes

As to APPLY Heapify(node) to any node its lhs and rhs subtrees must  have to be  HEAP.

Lower bound for heap is its HEIGHT given by log(n)

so it's answer must be A

4 votes
4 votes
Go ahead guys with next question without wasting your time. It's a poorly formed question. If this question repeats anywhere you will be able to answer Ω(log n) as it is the smallest. If this question repeats with Ω(1) in option then choose Ω(1) only.

Best Case $\rightarrow$ Ω(1)

Worst Case $\rightarrow$ O(log n)
Answer:

Related questions

72 votes
72 votes
4 answers
1
35 votes
35 votes
12 answers
2
go_editor asked Feb 12, 2015
30,386 views
A binary tree T has $20$ leaves. The number of nodes in T having two children is ______.