✨ Space and Time Complexity ✨
One of the most important concepts when studying DSA is the complexity of the algorithm
In this thread I will dive deep into what that means and how you can measure it 👇🏻
When learning algorithms you can measure how efficient the algorithm is by knowing how many lines of code it executes to run an algorithm for an input of size n.
However, it is very hard to measure exactly how many lines of code the algorithm takes.
This is why big O exists.
what is big O? 🤔
Big O is the most used asymptotic notation. Asymptotic notations are a way to approximate how many lines of code the algorithm executes relative to the input size which we will refer to as "n" for the rest of the thread
To understand Big O better I will explain it through an algorithm: Selection Sort
This algorithm sorts an array by looping through the whole array and for each element in the array it iterates through the rest of the array to find the smallest element to put it in the beginning
This image visualizes how selection sort works: