Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMBC CSMC 341 Red-Black-Trees-1

Similar presentations


Presentation on theme: "UMBC CSMC 341 Red-Black-Trees-1"— Presentation transcript:

1 UMBC CSMC 341 Red-Black-Trees-1
11 Insert 4 into this R-B Tree 14 2 15 1 7 5 8 Red node Black node 8/3/2007 UMBC CSMC 341 Red-Black-Trees-1

2

3 UMBC CSMC 341 Red-Black-Trees-1
Insertion Practice Insert the values 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty Red-Black Tree 8/3/2007 UMBC CSMC 341 Red-Black-Trees-1

4 Constructing a RB tree by inserting 2, 1, 4, 5, 9, 3, 6, 7
case 1 2 1 2 1 2 4 1 2 4 5 1 2 4 5 1 2 4 5 9 case 3 1 2 5 9 4 1 2 5 9 4 3 1 2 5 9 4 3 6 7 1 2 5 9 4 3 6 case 2 1 2 5 7 4 3 6 9

5 UMBC CSMC 341 Red-Black-Trees-2
65 50 80 10 70 90 60 62 Perform the following deletions, in the order specified Delete 90, Delete 80, Delete 70 8/3/2007 UMBC CSMC 341 Red-Black-Trees-2

6 case 2

7 case 1 rotate 50 about 65 Recolor 50 and 65 50 65 V+ 62 10 60 50 65 70 62 10 60 50 65 V+ 62 10 60 case 3 Rotate62 about 65 recolor 62, 65 and 60 case 4 Rotate62 about 60 recolor 62 and 60 50 50 65 V+ 60 10 62 10 62 60 65


Download ppt "UMBC CSMC 341 Red-Black-Trees-1"

Similar presentations


Ads by Google