#Day10 #100DaysOfCode
count the occurence of elements in array.
calculate cumulative sum of the count array.
the new position of elements in the array is the cumulative sum minus 1.
must go from backwards, traversing the count array.
time complexity O(n+k) where k is the maximum number in the array.
non comparison sorting algorithm. for best, average, and worst
with negative numbers, find the minimum element and store it at zero index.
counting sort works best when the range of the data (the maximum number) isn't too large compared to the array length. Because a count array of that length has to be created.
count the occurence of elements in array.
calculate cumulative sum of the count array.
the new position of elements in the array is the cumulative sum minus 1.
must go from backwards, traversing the count array.
time complexity O(n+k) where k is the maximum number in the array.
non comparison sorting algorithm. for best, average, and worst
with negative numbers, find the minimum element and store it at zero index.
counting sort works best when the range of the data (the maximum number) isn't too large compared to the array length. Because a count array of that length has to be created.