Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Pertemuan 13 AVL Tree Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1.

Similar presentations


Presentation on theme: "1 Pertemuan 13 AVL Tree Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1."— Presentation transcript:

1 1 Pertemuan 13 AVL Tree Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1

2 2 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mahasiswa dapat menghasilkan program modular untuk mengimplementasikan ADT AVL tree

3 3 Outline Materi Pengertian dan penggunaan AVL tree Contoh AVL Tree Inerting data AVL tree Deleting data AVL tree Contoh program AVL Tree

4 4 Introduced by Adelson-Velskii and Landis in 1962 Definition : –TL and TR are height balanced –|hL - hR|<=1  AVL Tree adalah Binary Search Tree yang mempunyai ketentuan : maksimum perbedaan height antara subtree kiri dan subtree kanan adalah satu Balance Factor, BF(T) : –TallLeft: –1 –TallRight: +1 –Balance: 0 4 kinds of rebalancing : –LL: left subtree of the left subtree –RR: right subtree of the right subtree –LR: right subtree of the left subtree –RL: left subtree of the right subtree AVL Tree

5 5 INSERT –case 1 : BF(T)=0 Operation on AVL Tree 54 70 Before Insert(80) 30 54 7030 80 After Insert(80) +1 0 0 00 –case 2 : BF(T)=+1 Insert in left subtree for BF(T)=+1. 54 70 Before Insert(10) 30 54 7030 80 After Insert(10) 80 10 +1 0 000 0

6 6 Case 3 : Insert in left subtree for BF(T)=-1 Case 4 : Insert in right subtree for BF(T)=+1 Case 5 : Insert in left subtree for BF(T)=+1 Case 6 : Insert in right subtree for BF(T)=-1 Operation on AVL Tree

7 7 Single Rotation : LL, RR Operation on AVL Tree 54 7030 80 +1 0 0 54 7030 80 +2 0 +1 88 54 8030 88 +1 0 0 0 70 0 LeftChild Parent RightChild

8 8 Double Rotation Operation on AVL Tree 60 80 20 90 +10 0 55 Before Insert(55) 10 40 5 0 0 30 50 0 0 60 80 20 90 -2 +1 0 10 40 5 +1 0 30 50 0 +1 60 80 40 90 20 50 10 30 55 5 40 60 20 80 0 0 +1 10 30 5 +1 55 50 0 0 Insert(55) 90 0 0 R1R2


Download ppt "1 Pertemuan 13 AVL Tree Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1."

Similar presentations


Ads by Google