ProgrammingHard

Upper bound: in the sorted keys 1, 3, 5, 5, 5, 8, 9 (0-based), what index does bisect_right / upper_bound return for x = 5?

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

Correct answer: B. 5

The upper bound is the first position whose value is greater than 5, which is index 5 (the value 8). Index 2 is the lower bound, the first 5.

More C Programming questions

Exams that ask this topic