Data Structures & AlgorithmsModerateTCS Digital · Infosys SP

Assertion (A): Binary search runs in O(log n) time on a sorted singly linked list. Reason (R): Binary search halves the search range in each step.

  1. A. A is true, but R is false
  2. B. Both A and R are true, and R is the correct explanation of A
  3. C. A is false, but R is true
  4. D. Both A and R are true, but R is not the correct explanation of A

Correct answer: C. A is false, but R is true

Halving the range is true, but reaching the middle of a linked list takes a linear walk, so the total is Θ(n) (n/2 + n/4 + …). A is false.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic