Mark As Completed Discussion

This tutorial is about two awesome, non-comparison-based sorting algorithms. While many sorting algorithms require a comparator function that compares two values at a time, these two and their family of non-comparison methods rely on other techniques instead. We'll cover counting sort and radix sort, which are both very efficient. Bucket sort is another one, but it's a close enough cousin of radix sort that we'll point to other references for more information on it.

Before going into details, we must keep in mind that any sorting algorithm has to scan the unsorted array at least once. This provides us the following important rule:

Any sorting algorithm will take at least O(n) time

This statement constrains the best possible shortest sorting time - we cannot sort an array in a time complexity less than O(n). Of course, there are sorting algorithms which take up significantly more time. Given this ambitious target of O(n), let's look at how counting sort and radix sort stack up.

Here's a preview of the final implementations, but we'll be sure to walk you through the theory before revealing them again!

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment