Searching a sorted array
1.[2p] How many comparisons does binary search need in the worst case on an array of elements?
How many comparisons does binary search need in the worst case on an array of elements?
2.[2p] What invariant does binary search maintain?
What invariant does binary search maintain?
3.[3p] Trace binary search for 13 in the array 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47. How many comparisons does it make?
Trace binary search for 13 in the array 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47. How many comparisons does it make?
4.[3p] The decision-tree lower bound for comparison-based search on elements is because
The decision-tree lower bound for comparison-based search on elements is because
5.[2p] Interpolation search can beat because
Interpolation search can beat because
6.[3p] Why is preferred to ?
Why is preferred to ?
7.[2p] In the array 2, 4, 4, 4, 7, 9, lower bound for 4 returns 1 and upper bound returns 4. What does the difference between them count?
In the array 2, 4, 4, 4, 7, 9, lower bound for 4 returns 1 and upper bound returns 4. What does the difference between them count?
8.[2p] Binary search on an array that is not sorted reports an error rather than a wrong answer.
Binary search on an array that is not sorted reports an error rather than a wrong answer.
9.[3p] Which are true of running binary search on a sorted linked list rather than a sorted array?
Which are true of running binary search on a sorted linked list rather than a sorted array?
Select all that apply