Skip to content
Azhimathi Mayam logoDSA Study HubPCCST303 · KTU · S3
B.Tech S3 (S) Examinations May 2026 (2024 Scheme)QP 06PCCST303112504Part B · Q15b3 marksCO4Module 4asked in 2 papers

Question 15b

Perform radix sort to sort the numbers 341, 22, 33, 122, 42, 5 and 4.

Topics: Radix sort

Watch this exact question run

Loading visualizer…

Solution

Assumptions:
  • LSD radix sort, base 10, FIFO buckets.

Largest key 341 has 3 digits → 3 passes. Single-digit keys such as 5 and 4 have tens and hundreds digits 0.

Array after each pass (generated)checked by code
Input341 22 33 122 42 5 4
After pass 1 (units)341 22 122 42 33 4 5
After pass 2 (tens)4 5 22 122 33 341 42
After pass 3 (hundreds)4 5 22 33 42 122 341

Totals: passes = 3

How to write it in the exam

PassBuckets (non-empty)Result
1 (units)1: 341 | 2: 22,122,42 | 3: 33 | 4: 4 | 5: 5341, 22, 122, 42, 33, 4, 5
2 (tens)0: 4,5 | 2: 22,122 | 3: 33 | 4: 341,424, 5, 22, 122, 33, 341, 42
3 (hundreds)0: 4,5,22,33,42 | 1: 122 | 3: 3414, 5, 22, 33, 42, 122, 341
How this answer was verified
  • Hand trace
  • tests/pyq-sorting.test.ts
  • radix_sort.c differential test

Similar questions