Q. In a binary search algorithm, if the target is less than the mid value, what should be the next step?
-
A.
Search the left half of the array
-
B.
Search the right half of the array
-
C.
Return the mid index
-
D.
Increase the mid index
Solution
If the target is less than the mid value, the next step is to search the left half of the array.
Correct Answer:
A
— Search the left half of the array
Learn More →
Q. What happens to the search space in each iteration of binary search?
-
A.
It doubles
-
B.
It halves
-
C.
It remains the same
-
D.
It increases linearly
Solution
In each iteration of binary search, the search space is halved, which contributes to its logarithmic time complexity.
Correct Answer:
B
— It halves
Learn More →
Q. What type of data structure is typically used to implement binary search?
-
A.
Linked list
-
B.
Stack
-
C.
Array
-
D.
Queue
Solution
Binary search is typically implemented on arrays, as they allow direct access to elements.
Correct Answer:
C
— Array
Learn More →
Q. Which of the following scenarios is a real-world application of binary search?
-
A.
Finding a name in a phone book
-
B.
Sorting a list of names
-
C.
Searching for a file in a directory
-
D.
Inserting an element in a linked list
Solution
Binary search is effectively used for finding a name in a sorted phone book.
Correct Answer:
A
— Finding a name in a phone book
Learn More →
Showing 1 to 4 of 4 (1 Pages)