ProgrammingHardTCS NQT · Infosys

The sorted array is {1, 3, 5, 7, 7, 9}. What is the index of the first element greater than 7?

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

Correct answer: B. 5

Indices 0 to 4 hold values up to 7, and index 5 holds 9, the first value greater than 7. This is the upper-bound index.

More C Programming questions

Exams that ask this topic