Which of the following best describes the time complexity of binary search in the average case?
O(log n)
O(n)
O(1)
O(n log n)
What is the key requirement for Binary Search to work correctly?
The array must have unique elements.
The array must be sorted.
The array must have an even number of elements.
The array must be circularly sorted.
What is the base case in a recursive implementation of binary search?
When the search interval becomes empty.
When the middle element equals the target element.
Both option1 and option2
When the target element is found.
In the worst-case scenario, how many comparisons will binary search perform on a sorted array of 16 elements?
32
16
8
4
Can Binary Search be used on an unsorted array?
No, the array must be sorted for Binary Search to function properly.
It depends on the implementation of Binary Search.
Yes, but it will have a linear time complexity.
Yes, it will still work correctly.
You have a sorted array that has been rotated an unknown number of times. Which algorithm is best suited for finding a specific element in this array?
Binary Search
Interpolation Search
Jump Search
Linear Search
How do you calculate the middle index in Binary Search to avoid potential overflow?
mid = left / 2 + right / 2
mid = (left + right + 1) / 2
mid = left + (right - left) / 2
mid = (left + right) / 2
In binary search, what happens if the target value is less than the middle element of the current search interval?
The search continues in the right half of the interval.
The middle element is compared with its adjacent elements.
The search terminates as the target is not found.
The search continues in the left half of the interval.
When searching for a value in a very large sorted array, which algorithm is generally more efficient?
Binary search
Linear search
What is the time complexity of Binary Search in the best-case scenario?