Question

Please answer the following questions. Thanks!

1. A BST is created (it is initially empty) where the key associated with the data in each node is an integer. Elements are added to the BST with these keys in this order: 5, 4, 8, 7, 6, 9, 3, 2, 1. (a) Draw the resulting BST. (b) What is the height of the tree?

2. Continuing, assume the keys of Exercise 5.6 are integers which are appened to a linked list of integers, i.e., the elements of the list will be 5, 4, 8, ..., 2, 1. Assume we always start from the head node when searching for an element. Complete this table which lists the number of comparisons that are made to locate each element in the list.

ElementNumber of Comparisons to Locate the Element 4

What is the average number of comparisons?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

So First vet ro be insented is 5 Next 4 ら 5 Next ㅋ , 5 Next g 0 ヲ 5 6 6 4 Final 2. HugRK 여. The BST is6 4 2 6 1 4*2 +541) Avege com Pa sm273

Now for element 1, Comparison= 1*5=5

for element 2, Comparison= 1*4=4

for element 3, Comparison= 1*3=3

for element 4, Comparison= 1*2=2

for element 5, Comparison= 1*1=1

for element 6, Comparison= 1*4=4

for element 7, Comparison= 1*3=3

for element 8, Comparison= 1*2=2

for element 9, Comparison= 1*3=3

So total comparison=27, Total nodes in BST=9

Average Comparison= 27/9=3

Add a comment
Know the answer?
Add Answer to:
Please answer the following questions. Thanks! 1. A BST is created (it is initially empty) where...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT