Question: 1. A binary search of a sorted array with 3 unique elements where the search is always successful can be viewed as an array
1. A binary search of a sorted array with 3 unique elements where the search is always successful can be viewed as an array with each element having a probability of being selected = 1/3 and the number of comparisons a binary search requires to find the element is shown inside the array. 2 1 Then the average number of comparisons would be A(3) = (1/3) [2 + 1 + 2] = 5/3 You will find the A(15) for an array with 15 elements for the same binary search algorithm. (a) Draw the 15-element array showing the number of comparisons needed to find each element. (b) Determine A(15) A(n) 2 2k-1): (c) In class, our formula for A(n) for binary search was developed to be (where n = k ;2- i=1 (k-1)2* +1 2-1 2-1 Plug your problem where n = 15 into the formula and show that it equals your answer = i-1 = (lg(n+1)1)(n+1)+1 n (d) Simplify the A(n) final answer I provided in (c) for very large values of n.
Step by Step Solution
3.39 Rating (143 Votes )
There are 3 Steps involved in it
a The 15element array showing the number of comparisons needed to find each element in a successful ... View full answer
Get step-by-step solutions from verified subject matter experts
