Page 248 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 248

Unit 13: Sorting




          Go down one level to find the right position for 7:                                   Notes












          Remove 15:










          Swap 15 with the last element of the heap. As 10 will be adjusted in the heap, its cell will no
          longer be a part of the heap, instead it becomes a position from the sorted array:










          Store 10 in the hole (10 is greater than the children of the hole)










          Remove 10:










          Swap 10 with the last element of the heap. As 7 will be adjusted in the heap, its cell will no longer
          be a part of the heap, instead it becomes a cell from the sorted array:














                                           LOVELY PROFESSIONAL UNIVERSITY                                   241
   243   244   245   246   247   248   249   250   251   252   253