360 views
1 votes
1 votes
Conversion of binary search tree into a Max heap takes:

O(n) time

O(nlog n) time

None

1 Answer

0 votes
0 votes
Any form of binary search tree can be converted into a complete binary tree in $\Theta(n)$ time.

And heapification of a complete binary tree into a max or a min heap can be done in $\Theta(n)$ time.

Overall , time would be $\Theta(n)$+$\Theta(n)$ = $\Theta(n)$

Related questions

9 votes
9 votes
2 answers
2
minal asked Dec 9, 2016
4,037 views
The number of ways , in which numbers 1,2,3,4,5 can be inserted into binary heap,such that resultant binary heap is max heap ?given ans :8
1 votes
1 votes
1 answer
3
Rohan Mundhey asked Nov 6, 2016
294 views
Suppose you have an array A[1...n] of n elements in arbitrary order, the following alternate implementation of build max-heap.This algorithm calls heapify starting at the...
0 votes
0 votes
1 answer
4
syedasafoora asked Nov 8, 2023
247 views
Consider the following algorithm for Build-Max-heap and the given array A=[ 47,96, 35, 54, 77, 65, 83]. Run this algorithm on the given array and redraw the heap and the ...