Introduction
In my view, it's unnecessary to know every algorithm and data structure, contrary to common belief. Instead, deep understanding of a select few is crucial. The rest you can learn when you need them.
So, what are the most important algorithms and data structures to know? I would say that the most important ones in a set are the ones that are essential to solve the most common problems in computer science and software engineering. Let's formalize this idea.
You can think of as a set containing all data structures and algorithms. Now, we need to define a subset containing the essential structures and algorithms.
For example, an essential subset of could be containing the following structures and algorithms:
And, to use this subset, we need to define a set containing common problems in computer science and software engineering.
For each problem , there exists a data structure or algorithm that solves efficiently.
Please don't place excessive importance on this notation, as it serves merely as an example. It is evident that some problems require solutions through data structures and algorithms not encompassed within .
I will define what I mean by "efficiently" in this context. The efficiency is measured by the time and space needed to solve using . We define that is efficient if:
Where denotes the input size.
Note that is the worst-case time complexity, what is acceptable for most problems, since the average cases are better. This definition is not strict, but it provides a general idea of what I mean by "efficiently".
Typically, includes structures and algorithms efficient for common problems. For example, in the best and average cases, these structures and algorithms have a time complexity of and a space complexity of . In the worst case, they have a time complexity of and a space complexity of .
DS / A | Insertion | Searching | Deletion | Traversal |
---|---|---|---|---|
AVL Tree | ||||
BST | ||||
DAG | ||||
BFS | - | - | ||
DFS | - | - | ||
Hash Table | - |
Therefore, focusing on the essential subset provides enough coverage to solve most common problems efficiently, eliminating the need to know all data structures and algorithms in .
References
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press.