Data Structure Time Complexity Question #15262
MCQ Single Best Answer Easy

QWhat is the time complexity of a binary search algorithm for finding an element in a sorted array of n elements in the worst case?

ID: #15262 Time Complexity 157 views
Question Info
#15262Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log n)
  • C O(n)
  • D O(n^2)
Correct Answer: Option B

Explanation

Binary search is a divide-and-conquer algorithm that repeatedly divides the search space in half. In each step, the middle element is compared with the target element, and the search space is reduced to either the left or right half. This process continues until the target element is found or the search space is empty. As binary search eliminates half of the search space in each step, the time complexity is logarithmic to the number of elements (n), denoted as O(log n).

Share This Question

Challenge a friend or share with your study group.