Which of the following best describes the advantage of binary search over linear search?
Binary search uses less memory.
Binary search has a faster average-case time complexity.
Binary search is easier to implement.
Binary search can be used on unsorted data.
What is the time complexity of Binary Search in the best-case scenario?
O(n)
O(1)
O(log n)
O(n log n)
In the worst-case scenario, how many comparisons will binary search perform on a sorted array of 16 elements?
16
32
4
8
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
What is the key characteristic of an array that makes Binary Search applicable?
The array must be of a fixed size.
The array must be sorted.
The array must contain only positive integers.
The array must be stored in contiguous memory locations.
If you need to perform frequent insertions or deletions in the middle of a dataset, is binary search the most suitable choice?
No
Yes
What is the time complexity of Binary Search in the worst-case scenario?
How do you calculate the middle index in Binary Search to avoid potential overflow?
mid = (left + right) / 2
mid = left + (right - left) / 2
mid = (left + right + 1) / 2
mid = left / 2 + right / 2
Which of the following is a key difference between the iterative and recursive approaches to binary search?
Recursive binary search can only be used on arrays, while iterative binary search can be used on any data structure.
Iterative binary search is generally more efficient.
Recursive binary search uses a loop, while iterative binary search uses function calls.
Iterative binary search uses a loop, while recursive binary search uses function calls.
Which of the following best describes the time complexity of binary search in the average case?