# יסודות מבנה נתונים תרגול 6 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky AVL TREES.

## Presentation on theme: "יסודות מבנה נתונים תרגול 6 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky AVL TREES."— Presentation transcript:

יסודות מבנה נתונים תרגול 6 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky AVL TREES

Trees Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

AVL Tree Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 1 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree

AVL Tree Example: 14 1711 753 4

AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree 14 177 45311 13

AVL Tree Example: Now insert 12 14 177 45311 13 12

AVL Tree Example: Now insert 12 14 177 45311 12 13

AVL Tree Example: Now the AVL tree is balanced. 14 177 45312 1311

AVL Tree Example: Now insert 8 14 177 45312 1311 8

AVL Tree Example: Now insert 8 14 177 45311 128 13

AVL Tree Example: Now the AVL tree is balanced. 14 17 7 4 53 11 12 813

AVL Tree Example: Now remove 53 14 17 7 4 53 11 12 813

AVL Tree Example: Now remove 53, unbalanced 14 17 7 4 11 12 813

AVL Tree Example: Balanced! Remove 11 14 17 7 4 11 128 13

AVL Tree Example: Remove 11, replace it with the largest in its left branch 14 17 7 4 8 12 13

AVL Tree Example: Remove 8, unbalanced 14 17 4 7 12 13

AVL Tree Example: Remove 8, unbalanced 14 17 4 7 12 13

AVL Tree Example: Balanced!! 14 17 4 7 12 13

Question 2 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 2 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 2 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 2 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 3 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 4 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 4 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 4 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 4 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 4 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 5 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 5 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 5 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 5 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Question 5 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky

Download ppt "יסודות מבנה נתונים תרגול 6 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky AVL TREES."

Similar presentations