Sort One Hundred Million Digits
Sort One Hundred Million Digits
You are tasked with sorting an unsorted collection of 100,000,000 integer digits. Each digit is guaranteed to be in the range of 0 through 9. Describe an algorithm to perform this sort, analyze its time and space complexity, and provide a defensible order-of-magnitude estimate for its runtime and memory usage on a modern machine using a compiled language.
Assume the digits were not necessarily generated uniformly. The collection is already in memory, and parsing text input is considered a separate cost. You should discuss both a packed one-byte representation and a typical wider integer representation for the digits. Consider that a modern machine might have a sustainable memory bandwidth of roughly 20-80 GB/s, but the exact hardware is not fixed.
AI interview prep
Core dilemma
Choosing an algorithm that leverages the fixed, small range of input values (0-9) to achieve optimal performance, rather than defaulting to general-purpose comparison sorts which would be unnecessarily complex and slower.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Sort One Hundred Million Digits
Sort One Hundred Million Digits
You are tasked with sorting an unsorted collection of 100,000,000 integer digits. Each digit is guaranteed to be in the range of 0 through 9. Describe an algorithm to perform this sort, analyze its time and space complexity, and provide a defensible order-of-magnitude estimate for its runtime and memory usage on a modern machine using a compiled language.
Assume the digits were not necessarily generated uniformly. The collection is already in memory, and parsing text input is considered a separate cost. You should discuss both a packed one-byte representation and a typical wider integer representation for the digits. Consider that a modern machine might have a sustainable memory bandwidth of roughly 20-80 GB/s, but the exact hardware is not fixed.