ProgrammingHardTCS NQT · Infosys

The sorted array is {1, 3, 6, 6, 8}. What is the index of the first occurrence of 6?

  1. A. 1
  2. B. 2
  3. C. 3
  4. D. 4

Correct answer: B. 2

Indices 0 and 1 hold 1 and 3, and index 2 is the first 6. A lower-bound binary search returns this index in O(log n).

More C Programming questions

Exams that ask this topic