ProgrammingVery hard

qsort is used on an array of records where several records have equal keys. Which statement is guaranteed by the C standard?

  1. A. Equal records always keep their input order
  2. B. Equal records always come out reversed
  3. C. Records with equal keys may end up in a different relative order than they started in
  4. D. qsort is stable only when the array has under 10 records

Correct answer: C. Records with equal keys may end up in a different relative order than they started in

The standard does not require qsort to be stable. An implementation may reorder records with equal keys, so code that depends on their order must add a tiebreaker key.

More C Programming questions

Exams that ask this topic