Question

In: Computer Science

a) The keys 20, 15, 25, 12 and 18 are inserted (totally 5 keys, in that...

a) The keys 20, 15, 25, 12 and 18 are inserted (totally 5 keys, in that order) into an initially empty AVL tree. Show the final AVL tree (just 1 tree) after all the insertions. b) Delete the root node from the final tree in a). Take the root’s successor (we used predecessor in project 2) as the replacement. Show the AVL tree after the deletion. c) Delete the key 12 from the resulted tree in b). Show the AVL tree after the deletion.

Solutions

Expert Solution

AVL Tree are basically Binary Search Tree with special quality of self-balancing such that difference between heights of left and right subtrees cannot be more than one for each and every node.

Insertion in the AVL tree is normally performed as BST insertion but along with that we also need to ensure that the difference between hight of left and right subtree should be not be more than one and we can do that by performing left and right rotation.

AVL tree helps to achieve time complexity of O(logn) for every operation (search, insert,delete), whether BST will take O(h) time and in case of skewed binary search tree it will take O(n) time.

a) Look at the insertion process node by node and after every insertion the tree will be height balanced.

Insert 20...

Insert 15...

Insert 25...

Insert 12...

Insert 18 and the final tree will look like this...

b) Delete root node from final tree i.e 20.

c) Delete key 12...

Happy Learning!


Related Solutions

Given the following numbers:   25 16 61 18 15 20 15 20 24 17 19 28,...
Given the following numbers:   25 16 61 18 15 20 15 20 24 17 19 28, derive the mean, median, mode, variance, standard deviation, skewness, kurtosis, range, minimum, maximum, sum, and count. Interpret your results. What is the empirical rule for two standard deviations of the data?
Given the following numbers: 25 16 61 18 15 20 15 20 24 17 19 28,...
Given the following numbers: 25 16 61 18 15 20 15 20 24 17 19 28, derive the mean, median, mode, variance, standard deviation, skewness, kurtosis, range, minimum, maximum, sum, and count. Interpret your results. What is the empirical rule for two standard deviations of the data?
Table - 02 Hardwood Concentration 5% 10% 15% 20% 7 12 14 19 8 17 18...
Table - 02 Hardwood Concentration 5% 10% 15% 20% 7 12 14 19 8 17 18 25 15 13 19 22 11 18 17 23 9 19 16 18 10 15 18 20 A manufacturer of paper used for making grocery bags is interested in improving the tensile strength of the product. Product engineering thinks that tensile strength is a function of the hardwood concentration in the pulp and that the range of hardwood concentrations of practical interest is between...
Given the following table: Probability X Y 20% 15% 30% 60% 25% 18% 20% 30% 20%...
Given the following table: Probability X Y 20% 15% 30% 60% 25% 18% 20% 30% 20% Calculate a) the covariance of X and Y, and b) the correlation coefficient. Select one: a. a) -20.64% b) -0.90 b. a) -20.18% b) -0.88 c. a) -17.89% b) -0.78 d. a) -19.20% b) -0.84 e. a) -18.35% b)-0.80
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25?...
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25? = 200 25a − 15? − 5? = 300 10? + 20? − 30? + 100? = 400 how to do flowchart using gauss elimination and lu decomposition method
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25?...
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25? = 200 25a − 15? − 5? = 300 10? + 20? − 30? + 100? = 400 how to write coding in matlab using lu decomposition
1. 20 18 23 30 20 12 23 9 15 a. find the mean, median, mode...
1. 20 18 23 30 20 12 23 9 15 a. find the mean, median, mode and range. b. Find the standard deviation by hand. (complete the chart). x x-x̅ (x-x̅)2
Week 1 2 3 4 5 6 Value 18 14 17 12 18 15 Calculate the...
Week 1 2 3 4 5 6 Value 18 14 17 12 18 15 Calculate the measures of forecast error using the naive (most recent value) method and the average of historical data (to 2 decimals). Naive method Historical data Mean absolute error Mean squared error Mean absolute percentage error
For the Following data: 5, 15, 18, 10, 8, 12, 16, 10, and 6 Find: a)...
For the Following data: 5, 15, 18, 10, 8, 12, 16, 10, and 6 Find: a) Q1 = 25%; Q2= 50%; Q3 = 75%. Quartile and IQR= Inter Quartile Range b) Box Plot Figure with Upper & Lower Limit, Whiskers and Outlier(s) if any PLEASE SHOW DETAIL OF YOUR SET UP, FORMULA, CALCULATION. PLEASE NO EXCEL! Thank you!
Treatments A B C D -5 -9 -15 -20 -4 -4 -18 -9 -5 -16 -8...
Treatments A B C D -5 -9 -15 -20 -4 -4 -18 -9 -5 -16 -8 -20 -15 -4 -18 I do not understand how to calculate the SSE for statistics. I was able to get the SSTR and MSTR but I just don't understand how to get the SSE from this info.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT