Q. In binary search, what is the purpose of calculating the mid index?
-
A.
To find the maximum element
-
B.
To divide the array into two halves
-
C.
To check for duplicates
-
D.
To sort the array
Solution
The mid index is calculated to divide the array into two halves for further searching.
Correct Answer:
B
— To divide the array into two halves
Learn More →
Q. Which of the following is a common modification to binary search for finding the first occurrence of a target?
-
A.
Use a linear search
-
B.
Continue searching in the left half even after finding the target
-
C.
Sort the array first
-
D.
Use a stack
Solution
To find the first occurrence, continue searching in the left half even after finding the target.
Correct Answer:
B
— Continue searching in the left half even after finding the target
Learn More →
Showing 1 to 2 of 2 (1 Pages)