What is the time complexity of Binary Search in the best-case scenario?
O(n)
O(n log n)
O(1)
O(log n)
You have an unsorted array, and you need to find a specific value. Is it more efficient to sort the array and then use binary search, or to directly apply linear search?
Directly use linear search
Sort and then use binary search
In terms of space complexity, how does the iterative binary search compare to the recursive one?
Iterative binary search generally uses less space.
Both have the same space complexity.
It depends on the size of the input array.
Recursive binary search generally uses less space.
You need to find the first occurrence of a target value in a sorted array with duplicates. Which algorithm is more efficient?
Binary search
Linear search
What value does binary search return if the target element is not present in the sorted array?
It depends on the implementation
-1
Index where the element should be inserted
Null
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?
Linear Search
Interpolation Search
Jump Search
Binary Search
What is the key characteristic of an array that makes Binary Search applicable?
The array must be of a fixed size.
The array must be stored in contiguous memory locations.
The array must be sorted.
The array must contain only positive integers.
In Binary Search, if the target value is less than the middle element, what should be the next step?
Conclude the target is not present.
Search the right half of the array.
Search the entire array again.
Search the left half of the array.
How does Binary Search handle duplicate elements in a sorted array?
It returns the index of the last occurrence of the target element.
It throws an error as Binary Search requires unique elements.
It returns the index of the first occurrence of the target element.
It returns the index of any one occurrence of the target element.
When searching for a value in a very large sorted array, which algorithm is generally more efficient?