Growing with the Web

Sorting algorithms

Published , updated
Tags:

A sorting algorithm takes a list of items and sorts them in a particular order, most commonly alphabetically or numerical.

The study of sorting algorithms is a great way to improve your craft as a software developer. They provide simple algorithms on which complexity analysis can be practised and also introduce some clever solutions to a simple and understandable problem.

Properties of a sorting algorithm

In addition to the time and space complexity of sorting algorithms, the below properties help define sorting algorithms.

Property Description
Adaptability An adaptive sort’s performance improves the more sorted the list is initially
In-place An in-place sort requires a constant amount of additional space
Parallelism A parallel sort can split its workload between multiple workers
Stability A stable sort preserves the order of items in the list that evaluate to the same value

Code

Algorithms presented in the articles below are available on GitHub are available in several languages including C#, Java, JavaScript, Python and Ruby.

Visualisations

Visualisations of the sorts powered by sorting-visualiser are available for supported algorithms on their respective pages.

See them all in action on the Sorting Visualiser project page.

Textbooks

Here are two CS textbooks I personally recommend; the Algorithm Design Manual (Steven S. Skiena) is a fantastic introduction to data structures and algorithms without getting to deep into the maths side of things, and Introduction to Algorithms (CLRS) which provides a much deeper, math heavy look.

 

Like this article?
Subscribe for more!