search
Log In
0 votes
38 views
MAX-HEAPIFY(A,i)

1   l=Left(i)
2   r=Right(i)
3   if l <= A.heapsize and A[l] > A[i]
4   largest=l
5   else largest = i
6   if r <= A.heapsize and A[r] > A[largest]
7   largest=r
8   if largest!=i
9   exchange A[i] with A[largest]
10  MAX-HEAPIFY(A,largest)

 

Using Figure 6.2 as a model, illustrate the operation of MAX-HEAPIFY(A,3) on the array $A=\langle 27,17,3,16,13,10, 1,5,7,12,4,8,9,0 \rangle$

 

in Algorithms 38 views

Please log in or register to answer this question.

Related questions

0 votes
0 answers
1
19 views
Show that the worst-case running time of MAX-HEAPIFY on a heap of size $n$ is $\Omega(lg\ n)$.(Hint: For a heap with $n$ nodes, give node values that cause MAXHEAPIFY to be called recursively at every node on a simple path from the root down to a leaf).
asked Jun 26, 2019 in Algorithms akash.dinkar12 19 views
0 votes
0 answers
2
25 views
The code for MAX-HEAPIFY is quite efficient in terms of constant factors, except possibly for the recursive call in line 10, which might cause some compilers to produce inefficient code. Write an efficient MAX-HEAPIFY that uses an iterative control construct (a loop) instead of recursion.
asked Jun 26, 2019 in Algorithms akash.dinkar12 25 views
0 votes
0 answers
3
0 votes
0 answers
4
17 views
What is the effect of calling MAX-HEAPIFY$(A, i)$ when the element $A[i]$ is larger than its children?
asked Jun 26, 2019 in Algorithms akash.dinkar12 17 views
...