in Algorithms retagged by
236 views
0 votes
0 votes
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 heap-
array whenever the swapping takes place. dry run this statement
in Algorithms retagged by
236 views

1 comment

reshown by

I hope this will solve the problem

0
0

1 Answer

0 votes
0 votes

Using build heap method, we will take the given binary tree in the form of array and then go directly to the last internal node (last internal will be at location floor(n/2)-1)  and from last internal node onwards the parent will ask its children that “am i at correct position” if yes then one by one every parent will ask else if not then swapping will be done. Similarly, 2nd last internal node will do it and so on… till root node (first internal node).

Time complexity= $\Theta$(n)

 

i hope you got it. Thank you.

Related questions