Data Structures & AlgorithmsVery hard

Why do the positions of a stable partition by parity keep their relative order, and why is that important?

  1. A. Partitioning always reverses the order.
  2. B. Stability only matters for sorting, not partitioning.
  3. C. A stable partition copies each group in input order, which is required when later steps depend on the original order.
  4. D. Stable partitions change every value.

Correct answer: C. A stable partition copies each group in input order, which is required when later steps depend on the original order.

Keeping relative order is what distinguishes a stable partition, and it is needed when subsequent logic depends on the original sequence inside each group.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic