Counting Sort

Counting Sort

Counting Sorting assumes that for each of the n input elements is an integer in the range 0 to k, for some integer k. When k=O(n) the sort runs in Θ(n) time.

Counting sort determines, for each input element x, the number of elements less than x. It uses this information to place element x directly into its position in the output array.

Latest Source Code:
Github: CountingSort.java


Output:

 Input : [2, 5, 3, 0, 2, 3, 0, 3]
Output : [0, 0, 2, 2, 3, 3, 3, 5]

Author: Hrishikesh Mishra