In what scenario would linear search be more suitable than binary search?
Finding the median value in a sorted array.
Searching for a specific value in a sorted array.
Searching for an element in a small, unsorted array.
Finding the smallest element in a rotated sorted array.
Can Binary Search be used on an unsorted array?
Yes, it will still work correctly.
Yes, but it will have a linear time complexity.
No, the array must be sorted for Binary Search to function properly.
It depends on the implementation of Binary Search.
How do you calculate the middle index in Binary Search to avoid potential overflow?
mid = left + (right - left) / 2
mid = (left + right + 1) / 2
mid = left / 2 + right / 2
mid = (left + right) / 2
What is the space complexity of Binary Search (iterative implementation)?
O(n)
O(n log n)
O(log n)
O(1)
What is the time complexity of Binary Search in the worst-case scenario?
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?
Interpolation Search
Linear Search
Jump Search
Binary Search
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 last occurrence of the target element.
It returns the index of any one occurrence of the target element.
It returns the index of the first occurrence of the target element.
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 is the base case in a recursive implementation of binary search?
Both option1 and option2
When the target element is found.
When the middle element equals the target element.
When the search interval becomes empty.
Which of the following is a prerequisite for using binary search on a dataset?
The data must contain only numerical values.
The data must be stored in a hash table.
The data must be sorted.
The data must be stored in a linked list.