What value does binary search return if the target element is not present in the sorted array?
-1
It depends on the implementation
Null
Index where the element should be inserted
Which data structure inherently benefits from the efficiency of binary search for searching operations?
Hash Table
Binary Search Tree
Linked List
Queue
What is the space complexity of Binary Search (iterative implementation)?
O(n log n)
O(n)
O(log n)
O(1)
How do you calculate the middle index in Binary Search to avoid potential overflow?
mid = left / 2 + right / 2
mid = (left + right + 1) / 2
mid = (left + right) / 2
mid = left + (right - left) / 2
What is the base case in a recursive implementation of binary search?
When the search interval becomes empty.
Both option1 and option2
When the middle element equals the target element.
When the target element is found.
In what scenario would linear search be more suitable than binary search?
Searching for a specific value in a sorted array.
Finding the median value in a sorted array.
Searching for an element in a small, unsorted array.
Finding the smallest element in a rotated sorted array.
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.
Iterative binary search generally uses less space.
Both have the same space complexity.
In the context of Binary Search, what is the problem with searching in an infinitely sized array?
Binary Search is too slow for infinitely sized arrays.
Binary Search requires the entire array to be loaded into memory.
Binary Search cannot handle arrays with no defined end.
Binary Search cannot handle duplicate elements in an infinitely sized array.
If we need to perform many searches in a sorted array, which of the following approaches will be the most efficient?
Sorting the array using Bubble Sort before each search and then performing Linear Search.
None of the above.
Sorting the array once using an efficient sorting algorithm and then performing Binary Search repeatedly.
Performing Linear Search repeatedly.
When searching for a value in a very large sorted array, which algorithm is generally more efficient?
Binary search
Linear search