There are 2 kinds of purpose of works.
- Better result. For the problem itself is optimization. Such as Shortest Path. Longest Common Subsequence, etc. You can get it from the names of algorithm.
- Better performance. That is why we talk about time and space complexity, optimization for add/remove or query operations.
It is right to think in the way that there are some measurement/metrics we can use to verify its optimization. Are you thinking what I am thinking? It is mathematics, or to be precise, algebra.
Some problems, at its surface, does not imply you should use data structures (such as tree or graph) or algorithm design (such greedy. backtracking, dynamic programming, etc. ) to solve it efficiently. However, you should know the hardest part of using right algorithm to solve your problem is to find which algorithm should be used, and how you should transform your original problem into a limited set of algorithm proposed-to-solve problems, and after getting the solution in algorithm form, transform it back to the solution in original form of the problem.
If you just read one textbook of algorithms, you are more likely to fix your map of problem-algorithm landscape. Here is one example of mine, maybe you have known it well.
- Heap is not the only way to implement Priority Queue. You can use AVL Tree.
- In turn, AVL Tree can be used for Sorting too.
- You can use Heap for Sorting too.
- Also, Priority Queue can be used in Dijkstra and Huffman Tree, and Prim's MST.
I wish I have confused you and then make the point that one DS or algorithms can use others and be used by others. It is safe to think it is always many-to-many mapping, rather than single-minded one-to-one or one-to-many.
- [Introduction to Algorithms, Third Edition(https://mitpress.mit.edu/books/introduction-algorithms)