Question

Transcribed Image Text:Binary search is performed on a sorted array of n elements. The search key is not in the array and falls
between the elements at positions m and m+1 (where 1 ≤ m <n). How many comparisons are needed in
the worst case scenario to determine that the key is not in the array?
a. ceil(log(n))
b. floor(log(n))
c. ceil(log(m))
d. floor(log(m))
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps

Knowledge Booster
Similar questions
- Let N be an unordered array of integers. The maximum number of compares required to find the minimum value is N. Select one True or Falsearrow_forwardthe drop down bar is the selection you have to choose from for each answerarrow_forwardIf a linear search is performed on an array, and it is known that some items are searched for more frequently than others, how can the contents of the array be reordered to improve the average performance of the search?arrow_forward
- The contents of the array below represent a BST (Binary Search Tree). What would be the contents of the array after 30 is deleted. Briefly explain how 30 would be deleted. Use an X to represent any empty spots in the array. 30 2050 10 25 40 60arrow_forwardThe algorithm: –In an array of n elements, go to index [n/2] –If the record there is the one you want, you are done –If the record value there is smaller than your search value, all records less than the current record can be ignored – set your search range of elements to [n/2+1…n] and return to step 1 –Otherwise, set your range of elements to [0…(n/2)-1] and return to step 1 –Repeat this loop until you have 0 elements (record is not found) or record is found Short answer Another approach to the update algorithm is to perform use the delete function for the old value and if it is successful, call the insert function using the new value. Explain in your own words if you think this approach is significantly better, worse, or in the same category as the algorithm discussed in the slides, and why.arrow_forwardThere exist sorting algorithms which can sort any list with N elements in O(N log N) time. True Falsearrow_forward
arrow_back_ios
arrow_forward_ios