יסודות מבנה נתונים
Post on 06-Feb-2016
51 Views
Preview:
DESCRIPTION
TRANSCRIPT
נתונים מבנה יסודות
6תרגול
Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky
AVL TREES
Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky
Trees
AVL Tree
Foundations of Data Structures - 2013/Spring, Amihai Savir & Ilya Mirsky
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
AVL Tree Example:
14
1711
7 53
4
AVL Tree Example:• Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree
14
177
4 5311
13
AVL Tree Example:• Now insert 12
14
177
4 5311
13
12
AVL Tree Example:• Now insert 12
14
177
4 5311
12
13
AVL Tree Example:• Now the AVL tree is balanced.
14
177
4 5312
1311
AVL Tree Example:• Now insert 8
14
177
4 5312
1311
8
AVL Tree Example:• Now insert 8
14
177
4 5311
128
13
AVL Tree Example:• Now the AVL tree is balanced.
14
17
7
4
53
11
12
8 13
AVL Tree Example:• Now remove 53
14
17
7
4
53
11
12
8 13
AVL Tree Example:• Now remove 53, unbalanced
14
17
7
4
11
12
8 13
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
174
7
12
13
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 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
top related