DSA (Data Structure and Algorithms) is a well known subject in past and modern programming environment, and despite all the fuzz about AI and how LLM’s models can/are/will change the way that we as software engineers solve problems, I still believe that understanding DSA concepts are gonna play a huge role on leveraging what LLM’s models can/how they write the code that we tell them to write. So without further do, let’s dive deep on the most important Data Structures and Algorithms.

🏢 Big O Notation

Big O Notation is a mathematical way to evaluate the efficiency of an algorithm. It describes how the runtime or memory usage of an algorithm grows as the size of the input increases. In other words, it helps us understand the scalability of algorithms and data structures by focusing on their performance trends rather than exact execution times.

image.png

<aside> 💡

"Big-O Complexity Chart" from Big-O Cheat Sheet, created by Eric Drowell.

</aside>

As we can see there is different types of complexities.

Being the most performant the green ones and the less performant the red ones in the chart.

Let’s understand what they mean:

*Binary search can be only applied in sorted lists - we will see that later.

Big O Notation consider the worst possible case, therefore if your code look like this:

function findSomething (target: number, data: Array<number>): number | null {	
	if (target === data[0]) return data[0];
	
	for(let i = 0; i < data.length; i++) {
		if (data[i] === target) {
			return data[i];
		}
	}
	
	return null;
}

<aside> 💡

Even if the target we are looking for is at the first index of the array, Big O Notation evaluates the worst-case scenario, where the algorithm might need to iterate through the entire data array. In this case, the complexity is O(n), because the algorithm uses a loop - a for loop - that potentially examines every element.

</aside>

🔍 Binary Search

Binary Search is a algorithm that uses the concept of DC (Divide and Conquer), basically this concept tells that you need to keep dividing your problem into smaller pieces until you find what your looking for or not.