Professional Documents
Culture Documents
Search Structures: All The Programs in This File Are Selected From
Search Structures: All The Programs in This File Are Selected From
Search Structures
FE M
B AR
AP JU M
R NE AY
AU JU SE
G LY PT
DE OC
C T
Max comparisons: 6 N
Average comparisons: 3.5 OV
A Balanced Binary Search Tree
For The Months of The Year
Input Sequence: JULY, FEB, MAY, AUG, DEC, MAR, OCT, APR, JAN,
JUNE, SEPT, NOV
Max comparisons: 4
JU
LY Average comparisons: 3.1
FE M
B AY
JA
AU M OC
N
G AR T
AP DE JU N SE
R C NE OV PT
Degenerate Binary Search
Tree
AP
R AU Input Sequence: APR, AUG, DEC, FEB,
G DE JAN, JULY, JUNE, MAR, MAY, NOV, OCT,
C FE SEPT
B JA
N JU
LY JU
NE M
AR M
AY N
Max comparisons: 12 OV OC
Average comparisons: 6.5 T SE
PT
Minimize The Search Time of Binary
Search Tree In Dynamic Situation
+1 +1
M M
AR AR -1
-1 -1 -1
AU M AU M
G AY G AY 0
0 +1 0 0 0
AP N AP JA N
JA
R OV R N OV
0
N 0 0
DE DE JU
C C LY
+1 +
2 0
A B
A
0 +1 0
B B A
h+2 h+2
AR h AR BL
BL BR BL BR
BR AR
height of BL increases
to h+1
Rebalancing Rotation RR
RR
-1 -
2 0
A B
A
0 -1 0
B B A
h+2 h+2
AL AL BR
BL BR BL BR
AL BL
height of BR increases
to h+1
Rebalancing Rotation LR(a)
+
+1 0
2
A C
A LR(a)
0 -1 0 0
B B B A
0
C
Rebalancing Rotation LR(b)
LR(b)
+ +
1 2 0
A A C
0 -
1 -
B 0
1
B B
h+2 A
+ h+2
0 AR h AR
1
C
C
h BL BL
CL CR CL CR h CL CR
BL AR
Rebalancing Rotation LR(c)
+
0
2
C
A
LR(c)
- +
0
1 1
A
B B
h+2
-
1 AR
C
BL CL CR
h BL AR
CL CR