Principles of Big O Notation

Photo by Icons8 Team on Unsplash

4 Important Rules of Big O Notation:

function something(){
doFirstStep(); // O(a)
doSecondStep(); // O(b)
} // ^ Together this would be:
O(a+b)
function minMax1(array) {
min, max <= NULL
for each e in array \ O(n) \
min = MIN(e, min) / \
for each e in array \ / O(n)
max= MAX(e, max) / O(n) /
}

function minMax2(array){ \
min, max <= NULL \
for each e in array \
min = MIN(e, min) / O(n)
max = MAX(e, max) /
} /
int intersectionSize(arrayA, arrayB){
int count = 0
for a in arrayA {
for b in arrayB{
if a == b {
count = count + 1
}
}
}
return count
}
function hello(array) {  \
max = NULL \
for each a in array{ \
max = MAX(a, max) / O(n)
} /
print max /
for each a in array { \
for each b in array { \
print a, b \
} / O(n^2)
} /
} /

--

--

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
Melissa Guachun

Software Developer and visual artist based in NYC. Join me on my journey to coding enlightenment or a torrential mental breakdown, whichever comes first.