Page 245 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 245

Fundamentals of Data Structures




                    Notes          Then, we check the children of 19, but both are smaller so no swap is needed:













                                   The children of 15 are 19 and 16, and is smaller, so a swap is required:













                                   Also, 15 is smaller than 17 one of the children, so it is again time to swap:














                                   Now the heap was built.














                                   Next, it is time to sort the heap:
                                   19, being the highest value, was removed from the top:
















          238                               LOVELY PROFESSIONAL UNIVERSITY
   240   241   242   243   244   245   246   247   248   249   250