Skip to content

Commit c790662

Browse files
committed
Count Sort
1 parent fed38c2 commit c790662

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lessons/countsort.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ description: "learn Sorting algorithms"
77
---
88
__________________________________________________________________________________________________________________
99

10-
# **Count Sort**
11-
1210
Counting sort is a sorting algorithm that sorts the elements of an array by counting the number of occurrences of each unique element in the array. In Counting sort, we maintain an auxiliary array which drastically increases space requirement for the algorithm implementation.
1311

1412
It works just like hashing, first, we calculate the max value in the input array, the array to be sorted. Then we count the number of occurrences of each array element from 0 to length-1 and assign it into the auxiliary array. This array is used again to retrieve the sorted version of the input array.
@@ -50,7 +48,7 @@ Consider the data in the range 0 to 9.
5048
1. Take a count array to store the count of each unique object.
5149

5250
Index: 0 1 2 3 4 5 6 7 8 9
53-
Count: 0 2 2 0 1 1 0 1 0 0
51+
Count: 0 2 2 0 1 1 0 1 0 0
5452

5553
2. Modify the count array such that each element at each index
5654
stores the sum of previous counts.

0 commit comments

Comments
 (0)