Order 3: Min Max All leaf nodes have null pointers! Susan Cooper
Data 1 2
Pointers 2 3
1 Insert
46 46
2 Insert
55 46 55
3 Insert
88
55
46 88
4 Insert
99
55
46 88 99
5 Insert
200 88
Successor of 55 not full
Rotate left to insert 200 46 55 99 200
6 Insert
120
Both children are full
Evaluate and split median (120)
88 120
46 55 200
7 Insert
300
88 120
46 55 200 300
8 Insert
400
88 200
Successor of 120 not full
Rotate left to insert 400
46 55 99 120 300 400
9 Insert
500
All levels are full
200
Evaluate and split median (400)
Split and bring down 88 from 200 88 400
46 55 99 120 300 500
10 Insert
12
200
Both children are full
Evaluate and split median (46)
46 88 400
12 99 120 300 500
11 Insert
59
200
46 88 400
12 55 59 99 120 300 500
12 Insert
62
200
55 88 400
12 46 59 62 99 120 300 500
13 Insert
98
Left subtree is full
Evaluate and split median (99)
200
55 88 400
12 46 59 62 99 300 500
98 120
Bring 99 up to 55|88 and there is room in 400
Count on right of root (200) is one…room to rotate and combine 200 with 400
Bring the greatest value of left side (99) up to root
98 attaches to right of 88 and 120 is a jumper to left of 200|400
99
55 88 200 400
12 46 59 62 98 120 500
14 Insert
93
.
99
55 88 200 400
12 46 59 62 93 98 120 500
15 Insert
47
Evaluate and split median (46)
.
99
55 88 200 400
46 59 62 93 98 120 500
12 47
Both children of root (99) is full
Evaluate and split median of 46|55|88 up to root
55 99
46 200 400
12 47 59 62 93 98 120 500
Now delete all values in the order they were inserted
Start with…
55 99
46 200 400
12 47 59 62 93 98 120 500
1 Delete
46
Both pred. and succ. are same count
Swap with pred. (12) and delete 46