Big O— For Beginners

If you get into Web development, Software Development or anything to do with writing code, you well eventually come across something called Big O Notation. It won’t make much sense in the beginning of your journey but when you start learning algorithms, applying for jobs or preparing for interviews, you’re going to need some knowledge of Big O.

What is Big O Notation?

Simply put, Big O is used to help us estimate the Run-time Complexity of a function and how it scales when the input increases. Meaning that if we give a function an Array with 10 items vs giving that same function an Array of 10,000 items, we want to understand the performance of that function with regards to input. When we see O(n), we are saying “Order of N”, where N is the input count. We will go over just a couple Big O complexities: O(1) — Constant, O(N) — Linear, O(n²) — Quadratic.

Image for post
Image for post
Fig 1. Big O run times

Constant Time — O(1):

Image for post
Image for post
Constant Time

Linear Time — O(n):

Image for post
Image for post

Quadratic Time — O(n^2):

Don’t be alarmed by the word “Quadratic”, after all the word “quadratic” comes from quadratum, the Latin word for square.

Image for post
Image for post
Quadratic Time

Written by

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