Here's a sample implementation of Radix sort, which internally implements count sort to store intermediate results. It sorts the data in O(n), yeah a linear sorting method. Amortized values will be O(kn) where k is the average length of typename. Sorting uses LSD -> MSB movement;
Also sample implementation is in C++ and works only for unsigned int. It can be typcased to work for int, long, float and even string.
http://code.google.com/p/samcoder/source/browse/trunk/codebase/src/RadixSort.h
http://code.google.com/p/samcoder/source/browse/trunk/codebase/test/RadixSortLSD.cpp
Radix Sort wiki -> http://en.wikipedia.org/wiki/Radix_sort
Happy Coding!
2 comments:
you stopped writing? :)
Haha!! you caught me!! i think i should move it to wordpress now :)
Post a Comment