Question:

Which of the following data structures supports binary search in \( O(\log n) \) time complexity?

Show Hint

Binary search is only efficient on sorted arrays because it relies on direct index access, which linked lists do not provide.
Updated On: Feb 15, 2025
  • An array of integers in increasing order
  • An array of integers in any order
  • A linked list of \( n \) integers in increasing order
  • A linked list of \( n \) integers in any order
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

- Binary search is highly efficient on sorted arrays, as it repeatedly divides the search space in half, leading to a time complexity of \( O(\log n) \). - If the array is unsorted (Option 2), binary search cannot be applied directly since it relies on order for correct operation. - Even if a linked list is sorted (Option 3), it does not support constant-time access to elements. Since accessing a specific element in a linked list requires traversal, binary search would take \( O(n) \), making it inefficient. - A linked list with elements in any arbitrary order (Option 4) is entirely unsuitable for binary search. Conclusion: Binary search achieves an optimal time complexity of \( O(\log n) \) only when used on a sorted array. Hence, the correct answer is (1) An array of integers in increasing order.
Was this answer helpful?
0
0