Which of the following statement(s) is/are true about binary search algorithm?…
2021
Which of the following statement(s) is/are true about binary search algorithm? I. It is implemented on sorted array. II. One must have direct access to the middle element in any sub-list. III. It is implemented on sorted linked list.
- A.
II and III
- B.
I and III
- C.
I and II
- D.
I, II and III
Attempted by 167 students.
Show answer & explanation
Correct answer: C
Binary search algorithm works efficiently only on sorted arrays. It requires direct access to any element in the array, which is possible due to indexing in arrays. This allows the algorithm to repeatedly divide the search space in half by accessing the middle element directly.
Statement I is correct because binary search is implemented on sorted arrays.
Statement II is correct because the algorithm must access the middle element of any sub-list directly, which is possible in arrays but not in linked lists.
Statement III is incorrect because linked lists do not support direct access to the middle element. Traversing to the middle requires O(n) time, which defeats the purpose of binary search's O(log n) efficiency.