Q. How does binary search determine the middle index of an array?
-
A.
(low + high) / 2
-
B.
low + high
-
C.
low * high
-
D.
high - low
Solution
Binary search calculates the middle index using (low + high) / 2 to find the midpoint of the current search range.
Correct Answer:
A
— (low + high) / 2
Learn More →
Q. What is the result of binary search if the target is less than the middle element?
-
A.
Search the left half
-
B.
Search the right half
-
C.
Return the middle element
-
D.
End the search
Solution
If the target is less than the middle element, binary search continues the search in the left half of the array.
Correct Answer:
A
— Search the left half
Learn More →
Showing 1 to 2 of 2 (1 Pages)