AVL TREES Height Balance : AVL Trees h 1 h 2 | h - h | 1 AVL - - PDF document
AVL TREES Height Balance : AVL Trees h 1 h 2 | h - h | 1 AVL - - PDF document
AVL TREES Height Balance : AVL Trees h 1 h 2 | h - h | 1 AVL AVL 2 1 non-AVL trees AVL trees S. Prasitjutrakul 1994 AVL Trees : I nsertion m m k k k u u k k m m v t u m m t t u k m u k u p v t k p v v
- S. Prasitjutrakul 1994
Height Balance : AVL Trees
AVL AVL
h2 h1 | h - h | ≤ 1
1 2
AVL trees non-AVL trees
- S. Prasitjutrakul 1994
AVL Trees : I nsertion
k k m m k u k m u m k u t v m k u t v p m k t p u v t m k p u v
Rotations
- S. Prasitjutrakul 1994
Rotations : Right High (Left Rotation)
A B C r x h h h+1 Total height = h+3 C B A r x h h h+1 Total height = h+2
- S. Prasitjutrakul 1994
Rotations : Left High (Double Rotation)
Total height = h+3
B C r x A h D h w h h C w x D h A r B h h h
Total height = h+2
- S. Prasitjutrakul 1994
Rotations : Left High (Double Rotation)
Total height = h+3
B C r x A h D h w h h-1 C w x D h A r B h h h-1
Total height = h+2
- S. Prasitjutrakul 1994
Rotations : Left High (Double Rotation)
Total height = h+3
B C r x A h D h w h-1 h C w x D h A r B h-1 h h
Total height = h+2
- S. Prasitjutrakul 1994
Deletion from an AVL Tree
A B A B A B A B B C A B C A
p p p p p q p q
- S. Prasitjutrakul 1994
Deletion from an AVL Tree
B C A B C A C D B A B A D C
p q p q p q r r p q
- S. Prasitjutrakul 1994
Deletion : Example
a g f e d c b k j h l i u p t s r
- n
m
deleted
- S. Prasitjutrakul 1994
Deletion : Example
a g f e d c b k j h l i t s r u
- n
m
deleted
p s r
- n
- S. Prasitjutrakul 1994
Deletion : Example
t s r u
- n
m
deleted
A
t s r u
- n
m
shorter
A
- S. Prasitjutrakul 1994
Deletion : Example
t s r u
- n
m
shorter
A
t s r u
- n
m
shorter
A
- S. Prasitjutrakul 1994
Deletion : Example
t s r u
- n
a g f e d c b k j h l i m
- S. Prasitjutrakul 1994
Deletion : Example
t s r u
- n
a e d c b j k l g f h i m
- S. Prasitjutrakul 1994
The Height of an AVL Tree
กํ าหนดให F คือ AVL tree ที่มีความสูง h ที่มีจํ านวน nodes นอยที่สุด และให | F | คือจํ านวน nodes ของตนไม F
h h h
F
h
F h
F h F h
Fibonacci Tree
worst-case bound