Unsorted Arrays vs Binary Search
1. What is the prerequisite for performing Binary Search on an array?
2. Binary Search is an example of which type of algorithm?
3. Let us assume the sorted array [1, 23, 145, 178, 1203]. How many iterations are needed to find 23 using binary search? Assume the index starts from 1 and the middle index is obtained by taking the floor of the midpoint.
4. Let us assume the sorted array [11, 33, 145, 1294, 1356, 1450, 3300, 4500, 6000, 8000, 9000]. Let us search for 4500 using binary search. What would be the middle values at the second and third iterations respectively? Assume the middle index is obtained by taking the floor of the midpoint and the index starts from 1.
5. What is the space complexity of binary search implemented using recursion, considering the recursive call stack?
6. In binary search, what happens to the search range after comparing the target with the middle element when the target is smaller than the middle element?
7. What is the worst-case time complexity of binary search on a sorted array containing elements?
8. Consider the sorted array [2, 5, 8, 12, 16, 20, 25]. Which element is examined first by a standard binary search?
9. If a binary search is applied to a sorted array and the target is equal to the middle element, what should the algorithm do?