ProgrammingHardTCS NQT · Infosys

The pairs (1,2), (3,5) and (2,5) are sorted by the second value descending, with ties broken by the first value ascending. Which pair comes first?

  1. A. (1,2)
  2. B. (3,5)
  3. C. (2,5)
  4. D. (3,2)

Correct answer: C. (2,5)

(3,5) and (2,5) tie on the second value 5, and the first value breaks the tie, so (2,5) comes before (3,5). (1,2) has the smallest second value and comes last.

More C Programming questions

Exams that ask this topic