Question 14Asked in Bihar STET Paper 2 Computer Science (Class 11-12), 12 Sep 2023, Shift 2

What is the worst-case time complexity of Binary Search for an array of size "n"?

  1. AO(log n)
  2. BO(n)
  3. CO(n log n)
  4. DO(1)
Show answerHide answer

Correct answer: (A) O(log n)

Explanation

Binary search halves the search range on every comparison, so at most about log₂n + 1 comparisons are needed: O(log n).

From Bihar STET Paper 2 Computer Science (Class 11-12) PYQ, 12 Sep 2023, Shift 2

This is question 14 of Bihar STET Paper 2 Computer Science (Class 11-12) PYQ, 12 Sep 2023, Shift 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.