Question

In: Computer Science

DEPTH counting starts at 1 at the root. Q1 [20 pts.]: Given the following key sequence...

DEPTH counting starts at 1 at the root.

Q1 [20 pts.]: Given the following key sequence (6,22,9,14,13,1,8) build the dynamic binary search tree WITHOUT BALANCING IT. How many probes (i.e., comparisons) does it take to determine that key 100 is not in the tree? (In this study case, the root is 6; the next element 22 > 6, so it goes to the right, etc).

Solutions

Expert Solution

Solution: Dynamic Binary Search Tree without balance it is as follows

key sequence (6,22,9,14,13,1,8)

Step 1: Insertion of the 1st element, i.e., 6 in our case.

Step 2: Insertion of 2nd element, i.e., 22; Here 22 > 6; therefore, 22 is the right child of 6.

Step 3: Insertion of 3rd element, i.e., 9; Here 9 > 6, therefore, it's the right children of 6, but 6 already have right children 22; and 9 < 22; therefore 9 is left children of 22.

Step 4: Insertion of 4th element, i.e., 14; Here 14 > 6 ; 14 < 22 ; 14 > 9. Therefore 14 is right children of 9.

Step 5: Insertion of 5th element, i.e., 13; Here 13 > 6 ; 13 < 22 ; 13 > 9 ; 13 < 14. Therefore 13 is left children of 14.

.

Step 6: Insertion of 6th element, i.e., 1; Here 1 < 6; Therefore, 1 is left children of 6.

Step 7: Insertion of 7th element, i.e., 8; Here 8 > 6 ; 8 < 22 ; 8 < 9. Therefore 9 is left children of 9.

Comparisons to determine key 100 is not in the tree: 2 comparisons will be needed to add 100 to this tree.

Comparison 1: 100 > 6, i.e., 100 is greater than 6, but the right children are already present, so traverse in the Right direction

Comparison 2: 100 > 22, i.e., 100 is greater than 22, and the right children of 22 is not present, so 100 is the right children of 22.

The graph after adding key 100 will be as shown below:

----------------------------------------------------------------------------------------------------------------------------------------------------------

Feel free to ask your queries in the comments, and please upvote if you got a satisfactory answer.


Related Solutions

DEPTH counting starts at 1 at the root. What should the loading factor be (on ANY...
DEPTH counting starts at 1 at the root. What should the loading factor be (on ANY HASH TABLE) if you want to have an average of 1.4 comparisons per successful search if LINEAR PROBING?
DEPTH counting starts at 1 at the root. How many total nodes does a 7-ary tree...
DEPTH counting starts at 1 at the root. How many total nodes does a 7-ary tree have if its depth is 8? Hash the given file (6,22,9,14,13,1,8) and use linear probing and the table size of 11. How many total collisions occurred? What is the loading density of the table?
Q1) Plot the root locus for the following systems where the given transfer function is located...
Q1) Plot the root locus for the following systems where the given transfer function is located in a unit negative feedback system, i.e., the characteristic equation is 1+KG(s)=0. Where applicable, the plot should indicate the large gain asymptotes, the angle of departure from complex poles, the angle of arrival at complex zeros, and breakaway points. Verify your answer using MATLAB (“rlocus” command) and show the results obtained from MATLAB. a) G(s) = (s + 4) (s + 2) 2 (s...
Problem 1. (20 Pts) Two storage structures, given code names Y and Z, are being considered...
Problem 1. (20 Pts) Two storage structures, given code names Y and Z, are being considered for a military base. The military uses a 6% percent/year expected rate of return and a 24-year life for decisions of this type. The relevant characteristics for each structure are shown below. Structure Y Structure Z First Cost 24225 24225 Estimated Life 12 years 24 years Estimated Salvage Value None $1,800 Annual Maintenance Cost $1,000 $720 a) What is the future worth of each...
Given is a sequence of the following pattern: {1, 2, 6, 24, 120, 720, …} 1....
Given is a sequence of the following pattern: {1, 2, 6, 24, 120, 720, …} 1. Write recursive equations for the above sequence. 2. Write a C++ recursive function that can compute the sequence in 1. above of any unsigned long number.
Compute Median, Q1, Q3, and IQR for the following data below Given: 10, 20, 12, 17,...
Compute Median, Q1, Q3, and IQR for the following data below Given: 10, 20, 12, 17, and 16 **Provide interpretation of your calculations**
1-Write all the balanced nuclear equations for each step of thenuclear decay sequence that starts...
1-Write all the balanced nuclear equations for each step of the nuclear decay sequence that starts with U-238 and ends with U-234. Refer to Figure 17.9 for the decay processes involved.2-Name one thing that all types of nuclear reactions have in common and one way in which they are different from each other.
Q1 Which of the following is a key determinant of the price elasticity of supply? a)...
Q1 Which of the following is a key determinant of the price elasticity of supply? a) the availability of substitutes in production b) the slope of the supply curve c) the time it takes to change output in response to a change in price d)the available technology Q2 Suppose when the price of jean jackets increased by 10 percent, the quantity supplied increased by 16 percent. Based on this information the price elasticity of supply of jean jackets is A)...
1. (20 pts) For each of the following statements, please circle T (True) or F (False)....
1. (20 pts) For each of the following statements, please circle T (True) or F (False). You do not need to justify your answer. (a) T or F? Any eigenvector of a matrix is in the column space of the matrix. (b) T or F? The number of singular values of a matrix is also its rank. (c) T or F? If A is an m × n with m < n, then the dimension of its column space is...
Given the sequence {an}∞ n=1 where an = 3ne−6n A) Justify whether the sequence is increasing...
Given the sequence {an}∞ n=1 where an = 3ne−6n A) Justify whether the sequence is increasing or decreasing. B) Is the sequence bounded? If yes, what are the bounds? C) Determine whether the sequence converges or diverges. State any reason (i.e result, theorems) for your conclusion.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT