I have written the MAX-HEAPIFY(A,i) method from the introduction to algorithms book. Now I want to write it …