Download presentation

Presentation is loading. Please wait.

Published byCason Lancey Modified over 3 years ago

1
Binary Search Trees Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 19 (continued) © 2002 Addison Wesley

2
Figure 19.1 Two binary trees: (a) a search tree; (b) not a search tree Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

3
Figure 19.2 Binary search trees (a) before and (b) after the insertion of 6 Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

4
Figure 19.3 Deletion of node 5 with one child: (a) before and (b) after Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

5
Figure 19.4 Deletion of node 2 with two children: (a) before and (b) after Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

6
Figure 19.13 Using the size data member to implement findKth Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

7
Figure 19.19 (a) The balanced tree has a depth of log N; (b) the unbalanced tree has a depth of N – 1. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

8
Figure 19.20 Binary search trees that can result from inserting a permutation 1, 2, and 3; the balanced tree shown in part (c) is twice as likely to result as any of the others. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

9
Figure 19.21 Two binary search trees: (a) an AVL tree; (b) not an AVL tree (unbalanced nodes are darkened) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

10
Figure 19.22 Minimum tree of height H Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

11
Figure 19.23 Single rotation to fix case 1 Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

12
Figure 19.25 Single rotation fixes an AVL tree after insertion of 1. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

13
Figure 19.26 Symmetric single rotation to fix case 4 Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

14
Figure 19.28 Single rotation does not fix case 2. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

15
Figure 19.29 Left–right double rotation to fix case 2 Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

16
Figure 19.30 Double rotation fixes AVL tree after the insertion of 5. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

17
Figure 19.31 Right–Left double rotation to fix case 3. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

18
Figure 19.34 A red–black tree: The insertion sequence is 10, 85, 15, 70, 20, 60, 30, 50, 65, 80, 90, 40, 5, and 55 (shaded nodes are red). Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

19
Figure 19.35 If S is black, a single rotation between parent and grandparent, with appropriate color changes, restores property 3 if X is an outside grandchild. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

20
Figure 19.36 If S is black, a double rotation involving X, the parent, and the grandparent, with appropriate color changes, restores property 3 if X is an inside grandchild. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

21
Figure 19.37 If S is red, a single rotation between parent and grandparent, with appropriate color changes, restores property 3 between X and P. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

22
Figure 19.38 Color flip: Only if X’s parent is red do we continue with a rotation. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley

Similar presentations

OK

Advanced Tree Data Structures Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.

Advanced Tree Data Structures Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on f5 load balancer Ppt on social media recruitment Ppt on elections in india download music Ppt on hcl technologies ltd Ppt on conservation of wildlife and natural vegetation of north Waters view ppt on mac Ppt on international business management Ppt on natural numbers symbol Ppt on number patterns in maths Ppt on nitrogen cycle and nitrogen fixation