יסודות מבנה נתונים

34
םםםםםם םםםם םםםםםם םםםםם6 Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky AVL TREES

Upload: yves

Post on 06-Feb-2016

51 views

Category:

Documents


0 download

DESCRIPTION

יסודות מבנה נתונים. תרגול 6. AVL Trees. Trees. AVL Tree. Question 1. Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree. AVL Tree Example :. 14. 11. 17. 7. 53. 4. AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree. 14. 7. 17. 4. 11. 53. 13. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: יסודות מבנה נתונים

נתונים מבנה יסודות

6תרגול

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

AVL TREES

Page 2: יסודות מבנה נתונים

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

Trees

Page 3: יסודות מבנה נתונים

AVL Tree

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

Page 4: יסודות מבנה נתונים

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

Question 1• Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree

Page 5: יסודות מבנה נתונים

AVL Tree Example:

14

1711

7 53

4

Page 6: יסודות מבנה נתונים

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

14

177

4 5311

13

Page 7: יסודות מבנה נתונים

AVL Tree Example:• Now insert 12

14

177

4 5311

13

12

Page 8: יסודות מבנה נתונים

AVL Tree Example:• Now insert 12

14

177

4 5311

12

13

Page 9: יסודות מבנה נתונים

AVL Tree Example:• Now the AVL tree is balanced.

14

177

4 5312

1311

Page 10: יסודות מבנה נתונים

AVL Tree Example:• Now insert 8

14

177

4 5312

1311

8

Page 11: יסודות מבנה נתונים

AVL Tree Example:• Now insert 8

14

177

4 5311

128

13

Page 12: יסודות מבנה נתונים

AVL Tree Example:• Now the AVL tree is balanced.

14

17

7

4

53

11

12

8 13

Page 13: יסודות מבנה נתונים

AVL Tree Example:• Now remove 53

14

17

7

4

53

11

12

8 13

Page 14: יסודות מבנה נתונים

AVL Tree Example:• Now remove 53, unbalanced

14

17

7

4

11

12

8 13

Page 15: יסודות מבנה נתונים

AVL Tree Example:• Balanced! Remove 11

14

17

7

4

11

128

13

Page 16: יסודות מבנה נתונים

AVL Tree Example:• Remove 11, replace it with the largest in its left branch

14

17

7

4

8

12

13

Page 17: יסודות מבנה נתונים

AVL Tree Example:• Remove 8, unbalanced

14

17

4

7

12

13

Page 18: יסודות מבנה נתונים

AVL Tree Example:• Remove 8, unbalanced

14

17

4

7

12

13

Page 19: יסודות מבנה נתונים

AVL Tree Example:•Balanced!!

14

174

7

12

13

Page 20: יסודות מבנה נתונים

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

Question 2

Page 21: יסודות מבנה נתונים

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

Question 2

Page 22: יסודות מבנה נתונים

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

Question 2

Page 23: יסודות מבנה נתונים

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

Question 2

Page 24: יסודות מבנה נתונים

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

Question 3

Page 25: יסודות מבנה נתונים

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

Question 4

Page 26: יסודות מבנה נתונים

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

Question 4

Page 27: יסודות מבנה נתונים

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

Question 4

Page 28: יסודות מבנה נתונים

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

Question 4

Page 29: יסודות מבנה נתונים

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

Question 4

Page 30: יסודות מבנה נתונים

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

Question 5

Page 31: יסודות מבנה נתונים

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

Question 5

Page 32: יסודות מבנה נתונים

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

Question 5

Page 33: יסודות מבנה נתונים

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

Question 5

Page 34: יסודות מבנה נתונים

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

Question 5