What is the space complexity of Binary Search (iterative implementation)?
O(1)
O(n)
O(log n)
O(n log n)
How does Binary Search handle duplicate elements in a sorted array?
It returns the index of the first 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 last occurrence of the target element.
What happens if the target element is not present in the array during Binary Search?
It enters an infinite loop.
It throws an exception.
It returns -1.
It returns the index where the element should be inserted.
What is the key characteristic of an array that makes Binary Search applicable?
The array must be sorted.
The array must contain only positive integers.
The array must be stored in contiguous memory locations.
The array must be of a fixed size.
What value does binary search return if the target element is not present in the sorted array?
It depends on the implementation
-1
Null
Index where the element should be inserted
What is the primary difference between Binary Search and Interpolation Search?
Binary Search only works on sorted arrays, while Interpolation Search can work on unsorted arrays.
Binary Search is faster than Interpolation Search in all cases.
Binary Search always divides the array in half, while Interpolation Search estimates the position of the target element.
Binary Search requires more memory than Interpolation Search.
What is the key requirement for Binary Search to work correctly?
The array must have an even number of elements.
The array must have unique elements.
The array must be circularly sorted.
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.
Can binary search be used to efficiently search for a target value in a rotated sorted array?
Yes, binary search can be directly applied.
No, binary search is not applicable to rotated sorted arrays.
Yes, but it requires modifications to handle the rotation.
It depends on the pivot point of the rotated 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 can be used on unsorted data.