Page 130 - DCAP605_ADVANCED_DATA_STRUCTURE_AND_ALGORITHMS
P. 130

Unit 6: Binary Search Tree and AVL Trees




                                                                                                Notes
                           Figure 6.3: Deletion of a Nod having Left and Right Child

                                                10


                                           6                12


                                       5          9
                                                        11

                                   4

                                                    8


          Now we need to, delete this empty node shown in Figure 6.3.

          Therefore, the final structure would be Figure 6.4.
                      Figure 6.4: Tree alter a Deletion of a Node having Left and Right Child

                                                   10
                                                               12
                                           7
                                                         11
                                    5
                                                 9

                                 4         8



          6.4.2 Deletion of a Node with one Child

          Consider the binary search tree shown below in Figure 6.5.

                        Figure 6.5: A Binary Tree before Deletion of a Node Pointed to by x
                                              50


                                                                y
                                                         60
                                30
                                             x                  65
                                                   52
                       25           35
                                            Nil
                                                          55
                              15


                                                   53            57


                                                         56             58




                                           LOVELY PROFESSIONAL UNIVERSITY                                   125
   125   126   127   128   129   130   131   132   133   134   135