293 views
1 votes
1 votes

Suppose you have an array A[1...n] of n elements in arbitrary order, the following alternate implementation of build max-heap.
image:P&DSS3/Q29a.PNG
This algorithm calls heapify starting at the root and working its way down the tree, instead of the other way around. 
For the given input A[1,2,3,4] what will be the output ?

1 Answer

0 votes
0 votes
the output will be

                     3

      4                            1

2

You cannot create a max heap by calling it in  top down manner, if u want to do it the max heapify must be modified or it must be applied in divide and conquer approach.

Related questions

1 votes
1 votes
1 answer
1
gate_forum asked Feb 13, 2019
360 views
Conversion of binary search tree into a Max heap takes:O(n) timeO(nlog n) timeNone
9 votes
9 votes
2 answers
3
minal asked Dec 9, 2016
4,034 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
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 ...