What is the space complexity of Binary Search (iterative implementation)?
O(log n)
O(n log n)
O(1)
O(n)
Can Binary Search be used on an unsorted array?
Yes, but it will have a linear time complexity.
Yes, it will still work correctly.
It depends on the implementation of Binary Search.
No, the array must be sorted for Binary Search to function properly.
Which of the following is a key difference between the iterative and recursive approaches to binary search?
Recursive binary search uses a loop, while iterative binary search uses function calls.
Iterative binary search is generally more efficient.
Recursive binary search can only be used on arrays, while iterative binary search can be used on any data structure.
Iterative binary search uses a loop, while recursive binary search uses function calls.
You need to find the first occurrence of a target value in a sorted array with duplicates. Which algorithm is more efficient?
Binary search
Linear search
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.
Performing Linear Search repeatedly.
Sorting the array once using an efficient sorting algorithm and then performing Binary Search repeatedly.
Which of the following best describes the time complexity of binary search in the average case?
In a rotated sorted array [5, 6, 7, 1, 2, 3, 4], what is the pivot element?
1
4
5
7
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 happens if the target element is not present in the array during Binary Search?
It returns -1.
It enters an infinite loop.
It throws an exception.
It returns the index where the element should be inserted.
In terms of space complexity, how does the iterative binary search compare to the recursive one?
Both have the same space complexity.
Iterative binary search generally uses less space.
Recursive binary search generally uses less space.
It depends on the size of the input array.