What is the primary advantage of using binary search over linear search for a sorted array?
Binary search is easier to implement.
Binary search uses less memory.
Binary search can handle duplicate elements more efficiently.
Binary search has a faster time complexity in most cases.
What is the key requirement for Binary Search to work correctly?
The array must have an even number of elements.
The array must be sorted.
The array must have unique elements.
The array must be circularly sorted.
What is the time complexity of Binary Search in the worst-case scenario?
O(log n)
O(n)
O(n log n)
O(1)
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 any one occurrence of the target element.
It returns the index of the first occurrence of the target element.
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?
Sort and then use binary search
Directly use linear search
In terms of space complexity, how does the iterative binary search compare to the recursive one?
It depends on the size of the input array.
Recursive binary search generally uses less space.
Both have the same space complexity.
Iterative binary search generally uses less space.
If we need to perform many searches in a sorted array, which of the following approaches will be the most efficient?
Sorting the array once using an efficient sorting algorithm and then performing Binary Search repeatedly.
Performing Linear Search repeatedly.
None of the above.
Sorting the array using Bubble Sort before each search and then performing Linear Search.
Which of the following best describes the advantage of binary search over linear search?
Binary search can be used on unsorted data.
Binary search has a faster average-case time complexity.
You need to find the first occurrence of a target value in a sorted array with duplicates. Which algorithm is more efficient?
Linear search
Binary search
In binary search, what happens if the target value is less than the middle element of the current search interval?
The middle element is compared with its adjacent elements.
The search continues in the left half of the interval.
The search terminates as the target is not found.
The search continues in the right half of the interval.