Psuedocode Implementation
suggest changeConstraints:
- Input (an array to be sorted)
- Number of element in input (n)
- Keys in the range of 0..k-1 (k)
- Count (an array of number)
Pseudocode:
for x in input:
count[key(x)] += 1
total = 0
for i in range(k):
oldCount = count[i]
count[i] = total
total += oldCount
for x in input:
output[count[key(x)]] = x
count[key(x)] += 1
return output
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents