Introduction to Counting Sort

Counting sort is a sorting algorithm that works by calculating the positions of each element in the output sequence. (Reading time: 4 minutes)

This algorithm first calculates how many times the same item occurs, and then adds all the values. We start off with the array we want to sort and initialize an index array. In this index array, we first store the number of times a particular value occurs in the array we want to sort.

Get hands-on with 1400+ tech skills courses.