Question
Suppose a binary search tree with 5 keys have a height of 3. Note that root is at depth zero. (a) Draw the best and
Suppose a binary search tree with 5 keys have a height of 3. Note that root is at depth zero.
(a) Draw the best and the worst binary search trees of height 3 that are possible with 5 keys.
(b) Assume that each key in the tree is searched with probability 1/5.
i. What is the expected number of comparisons for a successful search for the best search tree? ii. What is the expected number of comparisons for a successful search for the worst search tree?
(c) What is the expected number of comparisons for an unsuccessful search?
i. What is the expected number of comparisons for an unsuccessful search for the best search tree? ii. What is the expected number of comparisons for an unsuccessful search for the worst search tree?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started