Which of the following is the correct recurrence relation for the worst case…

2018

Which of the following is the correct recurrence relation for the worst case of binary search?

  1. A.

    T(n) = 2T(n/2) + O(1) ;

    T(1) = T(0) = O(1)

  2. B.

    T(n) = T(n/2) + O(n) ;

    T(1) = T(0) = O(1)

  3. C.

    T(n) = T(n/2) + O(1) ;

    T(1) = T(0) = O(1)

  4. D.

    T(n) = T(n/2) + O(log n) ;

    T(1) = T(0) = O(1)

Attempted by 311 students.

Show answer & explanation

Correct answer: C

In binary search , at each step the problem size is reduced to half (n/2) and only constant work O(1) is done for comparison. Therefore, the recurrence relation for the worst case is: T(n)=T(n/2)+O(1)

Explore the full course: Up Lt Grade Assistant Teacher 2025