Sort the following list using Radix sort algorithm. 329, 457, 839, 436, 720,…
2021
Sort the following list using Radix sort algorithm. 329, 457, 839, 436, 720, 355, 657 What is the output of the algorithm after 2nd pass?
- A.
720, 355, 436, 457, 657, 329, 839
- B.
720, 329, 436, 839, 355, 457, 657
- C.
329, 355, 436, 457, 657, 720, 839
- D.
355, 329, 457, 436, 720, 657, 839
Attempted by 118 students.
Show answer & explanation
Correct answer: B
Radix sort processes digits from least significant to most significant. We perform sorting in passes based on each digit. Initial list: 329, 457, 839, 436, 720, 355, 657 First Pass (Units Digit) Sort by the units digit (last digit): Digits: 9, 7, 9, 6, 0, 5, 7 After sorting by units digit: 720 (0), 436 (6), 457 (7), 657 (7), 329 (9), 839 (9), 355 (5) Wait, correction: 355 has units digit 5, so it should come before 436 (6). Correct order after first pass: 720 (0), 355 (5), 436 (6), 457 (7), 657 (7), 329 (9), 839 (9) Second Pass (Tens Digit) Now sort by the tens digit (middle digit): Digits: 2, 5, 3, 5, 2, 2, 3 Group by tens digit: 2 → 720, 329, 355; 3 → 436, 839; 5 → 457, 657 Within each group, maintain original relative order from first pass (stable sort): Tens digit 2: 720, 329, 355 Tens digit 3: 436, 839 Tens digit 5: 457, 657 Final order after second pass: 720, 329, 355, 436, 839, 457, 657 Note: The correct output after the second pass is 720, 329, 355, 436, 839, 457, 657.