Sorting Algorithms

Bubble Sort

In bubble sort, we compare items in pairs, moving the larger one to the right so it bubbles to the top.

Read More..

Selection Sort

If you had a look at bubble sort already (and if you haven’t, I encourage you to have a look), you might be wondering: why did we bother to compare each pair of dolls, one pair at a time? Why didn’t we just search through the whole list to find the the smallest doll, then […]

Read More..

Insertion Sort

Following selection sort and bubble sort (which are worth jumping back to if you’re new to this series and also new to algorithms!), there’s a third basic method of sorting that we have yet to explore: the insertion sort. With the insertion sort, rather than going pair-by-pair and swapping like we did with bubble sort […]

Read More..

Merge Sort

Now that we’ve had a look at some of the more basic sorting algorithms (bubble sort, selection sort, and insertion sort) which might be OK for smaller datasets but aren’t super efficient in general, let’s start to have a look at some of the more advanced algorithms for sorting. These algorithms (including merge sort, quick […]

Read More..