1 Pertemuan 13 AVL Tree Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1
2 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mahasiswa dapat menghasilkan program modular untuk mengimplementasikan ADT AVL tree
3 Outline Materi Pengertian dan penggunaan AVL tree Contoh AVL Tree Inerting data AVL tree Deleting data AVL tree Contoh program AVL Tree
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 INSERT –case 1 : BF(T)=0 Operation on AVL Tree Before Insert(80) After Insert(80) –case 2 : BF(T)=+1 Insert in left subtree for BF(T)= Before Insert(10) After Insert(10)
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 Single Rotation : LL, RR Operation on AVL Tree LeftChild Parent RightChild
8 Double Rotation Operation on AVL Tree Before Insert(55) Insert(55) R1R2