DEV Community

Cover image for Why Obama said, "I think Bubble Sort would be the wrong way to go.."
Khoj Badami
Khoj Badami

Posted on

Why Obama said, "I think Bubble Sort would be the wrong way to go.."

Let me share a quick clip with you first explaining the title...

Obama is right. Bubble sort would not be the way to go.

Why read this article? What will you get from it?

My goal with this article is to explain why. Not just a light overview.

A deep dive, which ends with bubble sort enlightenment.

Bubble Sort Enlightenment

Who this article is for?

If you have a formal education in computer science, you might not get much out of this article.

But, there are many self-taught developers like me, who got into programming without a formal education in computer science. We still know how to make web applications, mobile apps, games, and whatnot.

For my kind, this article might serve as a good introduction to computer science.

Is There A Void In Your Soul That NEEDS answers to...

  1. How does Bubble Sort Work?
  2. It takes different time to run based on different inputs. Why?
  3. How much time does it take in the worst-case & best case & why?
  4. How a simple trick can lead to a huge speedup in time? (This sounds like a clickbait title of some article, but it's not. I promise. 😋)
  5. How to calculate how much time it takes to run?
  6. Obama says it's slow! What does that really mean?
  7. Eric Schmidt says, "a million integers", how much time would Bubble Sort take to get thought that?
  8. Bonus topic: How to sum all the numbers from 1 up to some "n" like 1233212 quickly?

Okay, I guess your still here. Awesome! Let's fill that soul void! I'm excited.

There Is An Interactive Demo

You can stick in 6 different numbers until you have understood every facet of the algorithm. Click here to see it.

Part 1:: How Does Bubble Sort Work?

Part 2:: Optional (But fun, math thing that will help before you move ahead)

Part 3:: How to figure out how much time it takes? Why it's bad & why Obama was right after all.

Closing Comments

I hope you found some value & was a good introduction to computer science for you.

I am doing this project to feed my passion for teaching. Do let me know how I am doing. I want to make many more such demos + videos. The code behind the demo is open source. I am happy to answer questions about it too if any.

Top comments (0)