Here's a very horrible sorting algorithm that only works on integers ranging from 0 to size. I wouldn't use such an algorithm on a large set of data or one with large numbers in it because it would require so much memory. That consider, wouldn't this algorithm technically run in O(n) time?
Thanks
#include <iostream>
#define size 33
int main(){
int b[size];
int a[size] = {1,6,32,9,3,7,4,22,5,2,1,0};
for (int n=0; n<size; n++) b[n] = 0;
for (int n=0; n<size; n++){
if (size <= a[n]) throw std::logic_error("error");
b[a[n]]++;
}
int x = 0;
for (int n=0; n<size; n++){
for (int t=0; t<b[n]; t++){
a[x] = n;
x++;
}
}
for (int n=0; n<size; n++) printf("%d ",a[n]);
}