2:l= Left(i)
3:r= Right(i)
4:if l≤A.heap-size and A[l]<A[i] then
5:smallest=l
6:else
7:smallest=i
8:end if
9:if r≤A.heap-size and A[r]<A[i] then
10:smallest=r
11:end if
12:if smallest=i then
13:exchange A[i] with A[smallest]
14:MaxHeapify(A,smallest)
15:end if