Question

In: Computer Science

Given the sequence of numbers: 20, 7, 34, 29, 43, 40, 8, 12, 30, 42 (a)[7...

Given the sequence of numbers: 20, 7, 34, 29, 43, 40, 8, 12, 30, 42

(a)[7 pts] Show the resulting BST after inserting the numbers as keys.

(b)[9 pts] What will be the resulting tree if you delete the root? Show the tree and explain the steps taken in deleting the root according to the delete procedure we discussed in class.

(c)[9 pts] Can you reorder the original sequence of numbers to obtain a tree of a smaller height? If, yes, show the permutation of the sequence and the new tree. If no, argue why a smaller height is not obtainable.

Solutions

Expert Solution

Binary Search Tree

Step 1: Insert keys 20 & 7        

Step 2: Insert key 34                           

Step 3: Insert key 29

Step 4: Insert key 43                                                                

Step 5: Insert key 40     

Step 6: Insert key 8                                                                          

Step 7: Insert key 12           

Step 8: Insert key 30                                                                         

Step 9: Insert keys 42                 

which is Required Binary Search Tree after insertion

b) Delete Root:

Here we need to find out the Least value in Right Sub Tree

Swap Least value in Right Sub Tree and Root

Now Delete 20

Which is Required Tree after deleting Root

c) To obtain a tree of a smaller height then the sequence as follows

30, 8,42,7,12,40,43,29,34

The New tree as follows


Related Solutions

Price Quantity Supplied Quantity Demanded 8 50 20 7 40 25 6 30 30 5 20...
Price Quantity Supplied Quantity Demanded 8 50 20 7 40 25 6 30 30 5 20 35 4 10 40 Draw the supply curve and demand curve independently in a separate graph. Write the demand equation and the supply equation. Combine both curves in one graph and show the equilibrium price and quantity. What is the quantity demanded when the price is $10? Is there a shortage or surplus when the price equals $8? What about $4?
Given the data {20, 20, 30, 30, 40, 40, 50, 50, 60, 60}, calculate 1. Gini...
Given the data {20, 20, 30, 30, 40, 40, 50, 50, 60, 60}, calculate 1. Gini coefficient using the quintile distribution. 2. Draw the Lorenz curve with proper labels.
Using the data set below: Score Frequency 20-30 5 30-40 8 40-50 13 50-60 12 60-70...
Using the data set below: Score Frequency 20-30 5 30-40 8 40-50 13 50-60 12 60-70 5 Draw a Histogram Draw a polygon After listening to YouTube “histogram and polygon,” explain how histogram is different and similar to polygon.
For the following Grouped Frequency Distribution below : class 7-12 13-18 19-24 25-30 31-36 37-42 43-48...
For the following Grouped Frequency Distribution below : class 7-12 13-18 19-24 25-30 31-36 37-42 43-48 f 5 6 2 4 1 3 7 1) Find ( Mean , Mode , Standard Deviation , Variance ) 2) Sketch : Histogram , Polygon , and an Ogive
2017-2018 Goals 49 44 43 42 42 41 40 40 39 39 39 37 36 36...
2017-2018 Goals 49 44 43 42 42 41 40 40 39 39 39 37 36 36 35 35 34 34 34 34 2012-2013 Goals 32 29 28 26 23 23 23 22 22 21 21 21 20 20 20 19 19 18 18 18 2007-2008 Goals 65 52 50 47 43 43 42 41 40 40 38 38 36 36 35 34 34 33 33 32 Given the above three sets of data, we want to compare the three seasons...
Given the following information: Probability of Occurence Expected return 20% -5% 40% 5% 30% 7% 10%...
Given the following information: Probability of Occurence Expected return 20% -5% 40% 5% 30% 7% 10% 39% You are considering buying stock in Seller Inc. If Seller Inc's expected returns are as shown above, what is the standard devidation of the stock? (Hint: you first must find weighted average expected return). A. 8.999 B. 10.232 C. 11.524 D. 12.994 E. 14.506
Age HRS1 58 32 24 46 32 40 29 40 34 86 49 40 60 40...
Age HRS1 58 32 24 46 32 40 29 40 34 86 49 40 60 40 78 25 39 5 67 15 22 40 Develop a scatter plot with HRS1 (how many hours per week one works) as the dependent variable and age as the independent variable. Include the estimated regression equation and the coefficient of determination on your scatter plot. Does there appear to be a relationship between these variables (HRS1 and age)? Briefly explain and justify your answer....
43 77 36 40 47 47 39 33 51 43 34 41 31 32 31 23...
43 77 36 40 47 47 39 33 51 43 34 41 31 32 31 23 50 41 43 45 50 44 41 45 40 33 42 25 41 36 38 33 26 54 44 49 21 26 37 43 32 45 38 40 25 62 41 62 45 37 44 43 41 33 37 25 37 40 32 42 56 34 47 52 39 47 41 44 49 34 43 48 49 41 31 48 First, sort the data....
Salaries of men and women Woman Man 26 29 28 31 30 33 32 29 34...
Salaries of men and women Woman Man 26 29 28 31 30 33 32 29 34 33 48 56 52 54 22 28 27 33 You are trying to determine whether male and female Central Bank employees, having equal qualifications, receive different salaries. The data contain the salaries (in thousands of dollars) for 9 male and 9 female employees. Assume salaries are normally distributed. a. Assume that each row of data represents paired observations, and using alpha=0.05, can you conclude...
Calculate F Test for given 10, 20, 30, 40, 50 and 5,10,15, 20, 25. For 10,...
Calculate F Test for given 10, 20, 30, 40, 50 and 5,10,15, 20, 25. For 10, 20, 30, 40, 50:
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT