Data Structures & AlgorithmsHardTCS Digital · Infosys SP

LSD radix sort (base 10, stable sort on each digit, units digit first) is applied to [148, 261, 414, 335, 678, 773, 321]. What is the list after the SECOND pass (tens digit)?

  1. A. [414, 321, 335, 148, 261, 678, 773]
  2. B. [148, 261, 321, 335, 414, 678, 773]
  3. C. [414, 321, 335, 148, 261, 773, 678]
  4. D. [261, 321, 773, 414, 335, 148, 678]

Correct answer: C. [414, 321, 335, 148, 261, 773, 678]

Pass 1 orders by units: [261, 321, 773, 414, 335, 148, 678]. Pass 2 stably orders by tens, so ties keep the units order: [414, 321, 335, 148, 261, 773, 678]. Sorting by tens alone, ignoring pass 1, loses that tie order.

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

Exams that ask this topic