What’s Big O notation, faster runtime — Simply explained

reduce runtime so your algorithms can run as fast as possible. Image Credit: FLASH, THE COMIC

What’s the Idea of Big O?

Why We Care?

giphy.com — shrug
giphy.com — slow

Let’s Bring Up Two Functions to Compare

function number 1
function number 2
omg math!
giphy.com — think Sesame Street
function addUpTo(n) {return n * (n + 1)/2;}
function addUpTo(n) {let total = 0;for (let i = 1; i<= n; i++){   total += i;   
}
}
counting can be hard!

Introduce Big O

f(n) could be linear f(n) = n 
f(n) could be quadratic f(n) = n^²
f(n) could be constant f(n) = 1 

Bottom Line

Illustration by Adit Bhargava
Illustration by Adit Bhargava
function addUpTo(n) {return n * (n + 1)/2;}
function addUpTo(n) {let total = 0;for (let i = 1; i<= n; i++){total += i;   
}
}
giphy.com -smort

Sharing my learning journey in Coding

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