Sign in

Writer, reader and more…

Sort your elements with bubble sort

Bubble Sort Time complexity
Image from the author: Aniket

Why is it called Bubble Sort

Traditionally bubble sort got its name from a phenomenon where a bubble rises from the bottom of the water. Therefore, higher values rise from one end to the another by continuously comparing it with its next element.

In the modern world where C++ 11 introduced the sort function to sort arrays and vectors with time complexity of O(N log N), programmers often forget to read basic sorting techniques and completely rely on the sort() function. But to be completely honest it is a very wrong practice. We should always clear our basics before using shortcuts.

Let’s code Bubble Sort and…


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store