Page 264 - DCAP407_DATA_STRUCTURE
P. 264

Unit 14:  Heaps



               Let us discuss the implementation of heapsort using the following example.

                               Consider the following numbers 6,3,8,2,4,7,9. The tree representation of the set of
                               numbers can be seen in the figure 14.13.

                                              Figure 14.13 Tree for the List












               Let us now perform the first stage of heapification on the tree to make it balanced as shown in the figure
               14.14.

                                              Figure 14.14: Process of Heapification
















               We have obtained the heapified tree now (Refer figure 14.15) and we perform stage two which includes
               the deletion of the nodes.

                                              Figure 14.15: Heapified Tree























                                        LOVELY PROFESSIONAL UNIVERSITY                          257
   259   260   261   262   263   264   265   266   267   268   269