How does Binary Search handle duplicate elements in a sorted array?
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 the last occurrence of the target element.
It returns the index of any one occurrence of the target element.
In what scenario would linear search be more suitable than binary search?
Finding the smallest element in a rotated sorted array.
Searching for an element in a small, unsorted array.
Finding the median value in a sorted array.
Searching for a specific value in a sorted array.
Which of the following best describes the advantage of binary search over linear search?
Binary search has a faster average-case time complexity.
Binary search uses less memory.
Binary search is easier to implement.
Binary search can be used on unsorted data.
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 search terminates as the target is not found.
The search continues in the left half of the interval.
The middle element is compared with its adjacent elements.
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.
Recursive binary search generally uses less space.
It depends on the size of the input array.
When searching for a value in a very large sorted array, which algorithm is generally more efficient?
Linear search
Binary search
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
What is the time complexity of Binary Search in the worst-case scenario?
O(n log n)
O(1)
O(n)
O(log n)
You need to find the first occurrence of a target value in a sorted array with duplicates. Which algorithm is more efficient?
If we need to perform many searches in a sorted array, which of the following approaches will be the most efficient?
Performing Linear Search repeatedly.
None of the above.
Sorting the array using Bubble Sort before each search and then performing Linear Search.
Sorting the array once using an efficient sorting algorithm and then performing Binary Search repeatedly.