All about the Bubble Sorting Algorithm

All about the Bubble Sorting Algorithm

Micro-optimizations #3

Mads Cordes's photo
Mads Cordes
·Mar 15, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

Bubble Sort

What

The Bubble Sort is - of cause - an sorting algorithm. It's a simple one of it's kind, as you'll later see.

If you in the wild, wild west of CompSci sees an alorithm called Sinking Sort, it'll look a lot like the Bubble Sort, and really, it is the same thing. These are sometimes refered to as one or the other.

A Bubble Sort is not nearly as perfomant as some of its successors - and is mainly used as an educational algorithm nowadays.

Performance

As I mentioned, Bubble Sort is definitely not one of the fastest sorting algorithms out there, meaning its O-notion is O(n^2). which is never too good. Meaning it's slow.

Why

Why would you use the Bubble Sort then? Well, it's super easy to implement, which is also why people use it, and learn from it as - again - it's a great starting point.

Try

Below is an embed from hasty.dev, this is interactive. Try it yourself and check if you can speed up the Bubble Sort!

Powered by Hasty


{ Best, Mads Bram Cordes }

 
Share this

Impressum

Programming and things