Medium Algorithms Sorting Algorithms
How does radix sort work and what is its complexity?
Answer
Radix sort sorts integers digit by digit from least significant to most significant (LSD) or vice versa (MSD). Each digit pass uses stable counting sort. For n numbers with d digits and base b (typically 10 or 256), time is O(d*(n+b)), space is O(n+b). When d is constant, achieves O(n) - faster than comparison sorts' O(n log n) lower bound. Best for fixed-length integers or strings.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Software Engineer Algorithm Developer Systems Developer