The elements $42,25,30,40,22,35,26$ are inserted one by one in the given order into a max-heap. The resultant max-heap is stored in an array implementation as:
Insert elements one by one into max-heap.
After inserting $42,25,30$:
$\langle 42,25,30\rangle$
Insert $40$.
Since $40>25$, swap them:
$\langle 42,40,30,25\rangle$
Insert $22$:
$\langle 42,40,30,25,22\rangle$
Insert $35$.
Since $35>30$, swap them:
$\langle 42,40,35,25,22,30\rangle$
Insert $26$.
No swap is needed.
Final max-heap array is
$\langle 42,40,35,25,22,30,26\rangle$
Online Test Series, Information About Examination,
Syllabus, Notification
and More.
Online Test Series, Information About Examination,
Syllabus, Notification
and More.