Created
January 26, 2012 04:52
-
-
Save posaunehm/1681072 to your computer and use it in GitHub Desktop.
BucketSort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<int> BucketSort(IEnumerable<int> input) | |
{ | |
int[] bucket = new int[input.Max() + 1]; | |
foreach(var ele in input) | |
{ | |
bucket[ele]++; | |
} | |
return bucket.SelectMany((i, ele) => Enumerable.Range(0, i).Select(_ => ele)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment