The O() notation is an important concept for every Soft. Eng.

It is not only useful to pass coding interviews!

it’s the way we have to compare different processes (or algorithms) and speak about their efficiency (both in runtime and space.)

This is a 🧵thread about Big O 👇
The main feature of Big O: it’s a mathematical way of dealing with approximations.

When we say that an algorithm's runtime is O(n) we are saying that the time it takes for the code to finish is linearly correlated to the size of the input being processed (that's "n").

2/5
Linear Big O's are good. Every time you claim your code runs in O(n), you should be proud! 🥳

But you know what's even better? Constant time! ‼️

This one is represented as O(1): no matter how large is the input, your code will always take the same time to run.

3/5
Here are some examples of commonly known algorithms and their runtime in Big O:

▫️O(1): Array access
▫️O(ln n): Binary search
▫️O(n): Sequential search
▫️O(n lg n): Merge sort
▫️O(n^2): Selection sort
▫️O(c^n): Traveling Salesman

4/5
Mastering Big O Notation is not hard, and it will only take you doing some exercises to get a good handle of it.

And once you do, you’ll have a great way to compare and contrast different solutions to a problem!

5/5
You can follow @svpino.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: