Algorithms

Algorithms are essentially a way of getting from point A to point B. Therefore, many of the algorithms in this section will be accompanied by some sort of problem or question that the algorithm solves or answers.

In practice, it is unlikely that you will face the exact problems that these algorithms solve, but it's worth knowing them because many problems can be transformed into problems that these algorithms solve. This is the concept behind NP-Hard; A problem is said to be NP-Hard if any problem in NP can be transformed into it in polynomial time. In order to solve an NP-Hard problem, you simply need to know an NP problem, the solution to it, and how to transform it into the NP-Hard problem. The same can philosophy can be extended indefinitely to other, real-world problems, and is not confined to NP-Hard (just because a problem is not NP-Hard does not mean you cannot transform it into another problem you know the answer to).

As with data structures, this chapter only covers algorithms that are significant/well-known in computer science, or that are broadly applicable to most computer science fields. This means, for example, you wont find an algorithm for analyzing pictures of people to determine if they are smiling or frowning, nor will you find algorithms specific to artificial intelligence, meachine learning, etc. This chapter includes, primarily, algorithms that are applicable to most fields of computer science or have some value outside of niche use cases.

Ultimately, just knowing algorithms wont help that much. Here are some places where you can practice applying your knowledge of algorithms:

  • https://projecteuler.net/
  • https://leetcode.com/
  • https://www.codewars.com/
  • https://www.kaggle.com/

NOTE: Some algorithms simply have a link to other articles. Such is done for non-essential algorithms which are more valuable to simply know about than to know the implementation for.