Open In App

Java Program for Counting Sort

Last Updated : 14 Dec, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Counting sort is a sorting technique based on keys between a specific range. It works by counting the number of objects having distinct key values (kind of hashing). Then doing some arithmetic to calculate the position of each object in the output sequence.


Output: 
Sorted character array is eeeefggkkorss

 

Time Complexity: O(n+k) where n is the number of elements in the input array and k is the range of input. 
Auxiliary Space: O(n+k)

Please refer complete article on Counting Sort for more details!
 


Next Article
Practice Tags :

Similar Reads