ch12 carrano java - com sci · pdf filea 2-3-4 tree with the same items as the 2-3 tree in...

64
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem Solving with JAVA: Data Abstraction and Problem Solving with JAVA: Walls and Mirrors Walls and Mirrors Carrano Carrano / / Prichard Prichard Advanced Implementations Advanced Implementations of Tables of Tables

Upload: vannhan

Post on 05-Feb-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and MirrorsFrank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Data Abstraction and Problem Solving with JAVA:Data Abstraction and Problem Solving with JAVA:Walls and MirrorsWalls and Mirrors

CarranoCarrano / / PrichardPrichard

Advanced ImplementationsAdvanced Implementationsof Tablesof Tables

Page 2: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.1Figure 12.1A binary search tree of a) maximum height; b) minimum height

Page 3: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.2Figure 12.2A 2-3 tree of height 3

Page 4: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.3Figure 12.3Nodes in a 2-3 tree a) a 2-node; b) a 3-node

Page 5: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.4Figure 12.4A 2-3 tree

Page 6: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.5Figure 12.5a) A balanced binary search tree; b) a 2-3 tree with the same elements

Page 7: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.6Figure 12.6a) The binary search tree of Figure 12.5a after a sequence of insertions; b) the2-3 tree of Figure 12.5b after the same insertions

Page 8: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.7Figure 12.7After inserting 39

Page 9: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.8Figure 12.8a), b) The steps for inserting 38; c) the resulting tree

Page 10: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.9Figure 12.9After inserting 37

Page 11: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.10Figure 12.10a), b), c) The steps for inserting 36; d) the resulting tree

Page 12: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.11Figure 12.11The tree after the insertion of 35, 34, and 33

Page 13: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.12Figure 12.12Splitting a leaf in a 2-3 tree

Page 14: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.13Figure 12.13Splitting an internal node in a 2-3 tree

Page 15: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.14Figure 12.14Splitting the root of a 2-3 tree

Page 16: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.15aFigure 12.15aa), b), c), d) The steps for deleting 70

Page 17: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.15b-dFigure 12.15b-da), b), c), d) The steps for deleting 70

Page 18: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.15eFigure 12.15ee) the resulting tree

Page 19: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.16Figure 12.16a), b), c) The steps for deleting 100; d) the resulting tree

Page 20: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.17aFigure 12.17aThe steps for deleting 80

Page 21: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.17b and 12.17cFigure 12.17b and 12.17cThe steps for deleting 80

Page 22: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.17d and 12.17eFigure 12.17d and 12.17eThe steps for deleting 80

Page 23: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.18Figure 12.18Results of deleting 70, 100, and 80 from a) the binary search tree of Figure12.5a and b) the 2-3 tree of Figure 12.5b

Page 24: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.19a and 12.19bFigure 12.19a and 12.19ba) Redistributing values; b) merging a leaf

Page 25: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.19c and 12.19dFigure 12.19c and 12.19dc) redistributing values and children; d) merging internal nodes

Page 26: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.19eFigure 12.19ee) deleting the root

Page 27: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.20Figure 12.20A 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b

Page 28: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.21Figure 12.21A 4-node in a 2-3-4 tree

Page 29: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.22Figure 12.22Inserting 20 into a one-node 2-3-4 tree

Page 30: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.23Figure 12.23After inserting 50 and 40

Page 31: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.24Figure 12.24The steps for inserting 70

Page 32: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.25Figure 12.25After inserting 80 and 15

Page 33: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.26Figure 12.26The steps for inserting 90

Page 34: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.27Figure 12.27The steps for inserting 100

Page 35: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.28Figure 12.28Splitting a 4-node root during insertion

Page 36: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.29Figure 12.29Splitting a 4-node whose parent is a 2-node during insertion

Page 37: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.30Figure 12.30Splitting a 4-node whose parent is a 3-node during insertion

Page 38: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.31Figure 12.31Red-black representation of a 4-node

Page 39: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.32Figure 12.32Red-black representation of a 3-node

Page 40: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.33Figure 12.33A red-black tree that represents the 2-3-4 tree in Figure 12.20

Page 41: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.34Figure 12.34Splitting a red-black representation of a 4-node that is the root

Page 42: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.35Figure 12.35Splitting a red-black representation of a 4-node whose parent is a 2-node

Page 43: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.36aFigure 12.36aSplitting a red-black representation of a 4-node whose parent is a 3-node

Page 44: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.36bFigure 12.36bSplitting a red-black representation of a 4-node whose parent is a 3-node

Page 45: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.36cFigure 12.36cSplitting a red-black representation of a 4-node whose parent is a 3-node

Page 46: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.37Figure 12.37a) An unbalanced binary search tree; b) balanced tree after rotation;c) a balanced tree after insertion

Page 47: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.38Figure 12.38a) An unbalanced binary search tree; b) a balanced tree after a single leftrotation

Page 48: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.39Figure 12.39Before and after a single left rotation that decreases the tree’s height

Page 49: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.40Figure 12.40a) An unbalanced binary search tree; b) a balanced tree after a single leftrotation

Page 50: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.41Figure 12.41Before and after a single left rotation that does not affect the tree’s height

Page 51: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.42Figure 12.42a) Before; b) during; and c) after a double rotation

Page 52: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.43Figure 12.43Before and after a double rotation that decreases the tree’s height

Page 53: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.44Figure 12.44Address calculator

Page 54: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.45Figure 12.45A collision

Page 55: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.46Figure 12.46Linear probing with

h(x) = x mod 101

Page 56: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.47Figure 12.47Quadratic probing with

h(x) = x mod 101

Page 57: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.48Figure 12.48Double hashing during the

insertion of 58, 14, and 91

Page 58: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.49Figure 12.49Separate chaining

Page 59: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.50Figure 12.50The relative efficiency of four collision-resolution methods

Page 60: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.51Figure 12.51Two data structures that share the same data: a) a sorted linked list; b) areference-based queue

Page 61: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.52Figure 12.52A queue referencing a sorted linked list

Page 62: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.53Figure 12.53A queue referencing into a doubly linked list

Page 63: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.54Figure 12.54A queue referencing a double linked binary search tree

Page 64: Ch12 Carrano Java - Com Sci · PDF fileA 2-3-4 tree with the same items as the 2-3 tree in Figure 12-6b. Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M

Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley

Figure 12.55Figure 12.55A red-black tree for Exercise 7