DEV Community

Cover image for Why is bubble sort called 'Bubble Sort'?
Sakshi
Sakshi

Posted on

Why is bubble sort called 'Bubble Sort'?

I have read many contents on bubble sort, but found one same reason for this name. The reason they said is:

Because its easy to swap soap bubble/watter bubble, and that is what we do in bubble sort, we swap those elements which satisfy our condition.

Today I got to know a good, a real-like reason while reading a blog. The reason is :

Air bubbles that are more buoyant than surrounding water rise to the top. Similarly, list elements with greater value than their surrounding elements “bubble” to the end of the list.

Thanks for reading...

Top comments (1)

Collapse
 
moopet profile image
Ben Sinclair

Because its easy to swap soap bubble/watter bubble

I've just performed this experiment in my Scented Experminent Bath and I can tell you it's not that easy.