Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

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

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

4 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

5 AVL Tree Example: 14 1711 753 4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

34 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


Ads by Google