I did’nt get the part of counting the frequencies of all the digits
Doubt in counting sort code
@anika203a it is the basis of counting sort.
Once you count the frequencies of all the numbers then from a lowest possible value to highest possible value just print every digits as per their frequencies.
for ex: arr = 3 3 2 1 2
freq[3] = 2,freq[2]=2,freq[1]=1,
run a for loop from i = 1 to i=3:
at i = 1,freq[1] is 1 so print 1 single time,
at i=2 freq[2] is 2 so print 2 twice,
at i=3 freq[3] is 2 so print 3 twice
so after this for loop your output will look like this 1 2 2 3 3 which is sorted order of given array.
Yeah I got that how that frequency is used for printing them in sorted order… but I wanted to know that how is the frequency being counted over there for each number
just run a simple for loop till possible max size of any element.
Yeah got the logic thanks