Algorithms

Here it is, from thirty-thousand feet, as they say.

Why Study Algorithms

Studying algorithms helps you develop widely applicable analytical skills—you learn not just how to solve individual problems but to develop recipes for getting answers to many problems.

“A person well-trained in computer science knows how to deal with algorithms: how to construct them, manipulate them, understand them, analyze them. This knowledge is preparation for much more than writing good computer programs; it is a general-purpose mental tool that will be a definite aid to the understanding of other subjects, whether they be chemistry, linguistics, or music, etc. The reason for this may be understood in the following way: It has often been said that a person does not really understand something until after teaching it to someone else. Actually, a person does not really understand something until after teaching it to a computer, i.e., expressing it as an algorithm . . . An attempt to formalize things as algorithms leads to a much deeper understanding than if we simply try to comprehend things in the traditional way.” — Donald Knuth

And:

“Algorithmics is more than a branch of computer science. It is the core of computer science, and, in all fairness, can be said to be relevant to most of science, business, and technology.” — David Harel

Classifying Algorithms

Primary dimensions:

Secondary concerns include:

Problem Domain

What kind of a problem are you trying to solve?

Complexity Class

Let $n$ be the input size and $k$ be a fixed constant.

Underlying Data Structure

There is a huge list of data structures at Wikipedia, but here are some of the more common ones:

Strategies

This isn’t a complete list, but it covers some of the more famous ones:

Learning and Applying the Strategies

There are so many strategies that ultimately, you just have to gain a lot of experience seeing the various strategies applied in context.

But we can take advantage of those that came before us and provided nice little overviews of various strategies with specific problems and “when to apply it” guides. One very useful guide is this one by Himanshu Singour.

Exercise: Browse the article now. After a couple months of formal study of algorithms, reread the article in detail.

Recall Practice

Here are some questions useful for your spaced repetition learning. Many of the answers are not found on this page. Some will have popped up in lecture. Others will require you to do your own research.

  1. What are the four primary dimensions of algorithm classification?
    Domain, complexity class, underlying data structure, and problem solving strategy.
  2. What are some secondary concerns when classifying algorithms?
    Whether the algorithm is sequential or parallel, deterministic or randomized, whether it finds one solution or all solutions, whether it finds any solution or the optimal solution, whether it finds an exact or approximate solution.
  3. What is a decision problem?
    One where the algorithm determines whether a certain condition is true or false.
  4. What is a functional problem?
    One where the algorithm computes a value for a function.
  5. What is a constraint problem?
    One where the algorithm finds any input that satisfies a given condition.
  6. What is an optimization problem?
    One where the algorithm finds the input that minimizes or maximizes a function.

Summary

We’ve covered:

  • Why study algorithms
  • Dimensions of algorithm classification
  • A big list of algorithm strategies