Q. In which scenario would binary search be preferred over linear search?
-
A.
When the array is small
-
B.
When the array is unsorted
-
C.
When the array is large and sorted
-
D.
When searching for multiple elements
Solution
Binary search is more efficient for large sorted arrays compared to linear search.
Correct Answer:
C
— When the array is large and sorted
Learn More →
Q. What is the worst-case scenario for binary search?
-
A.
Finding the first element
-
B.
Finding the last element
-
C.
Finding an element not in the array
-
D.
Finding the middle element
Solution
In the worst case, binary search will check all levels of the tree, which is O(log n), but it will not find the element.
Correct Answer:
C
— Finding an element not in the array
Learn More →
Q. Which of the following is NOT a characteristic of binary search?
-
A.
It requires a sorted array
-
B.
It can be implemented recursively
-
C.
It can be implemented iteratively
-
D.
It works on unsorted data
Solution
Binary search does not work on unsorted data; it requires the data to be sorted.
Correct Answer:
D
— It works on unsorted data
Learn More →
Showing 1 to 3 of 3 (1 Pages)