bulid max heap

89

19 40

17 12 10 2

5 7 11 6 9 70 90

(2,90) and (10,70) not support max heap properties interchange it

89

19 40

17 12 70 90

5 7 11 6 9 10 2

after that (40,90) and (90,89) also we have to interchange to get max heap so 4 swap required

90

19 89

17 12 70 40

5 7 11 6 9 10 2

89

19 40

17 12 10 2

5 7 11 6 9 70 90

(2,90) and (10,70) not support max heap properties interchange it

89

19 40

17 12 70 90

5 7 11 6 9 10 2

after that (40,90) and (90,89) also we have to interchange to get max heap so 4 swap required

90

19 89

17 12 70 40

5 7 11 6 9 10 2