AVL TREES Height Balance : AVL Trees h 1 h 2 | h - h | 1 AVL - - PDF document

avl trees height balance avl trees
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

AVL TREES

slide-2
SLIDE 2
  • S. Prasitjutrakul 1994

Height Balance : AVL Trees

AVL AVL

h2 h1 | h - h | ≤ 1

1 2

AVL trees non-AVL trees

slide-3
SLIDE 3
  • 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

slide-4
SLIDE 4
  • 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

slide-5
SLIDE 5
  • 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

slide-6
SLIDE 6
  • 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

slide-7
SLIDE 7
  • 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

slide-8
SLIDE 8
  • 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

slide-9
SLIDE 9
  • 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

slide-10
SLIDE 10
  • 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

slide-11
SLIDE 11
  • 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
slide-12
SLIDE 12
  • S. Prasitjutrakul 1994

Deletion : Example

t s r u

  • n

m

deleted

A

t s r u

  • n

m

shorter

A

slide-13
SLIDE 13
  • S. Prasitjutrakul 1994

Deletion : Example

t s r u

  • n

m

shorter

A

t s r u

  • n

m

shorter

A

slide-14
SLIDE 14
  • S. Prasitjutrakul 1994

Deletion : Example

t s r u

  • n

a g f e d c b k j h l i m

slide-15
SLIDE 15
  • S. Prasitjutrakul 1994

Deletion : Example

t s r u

  • n

a e d c b j k l g f h i m

slide-16
SLIDE 16
  • 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