Kevin Sun

Why learn algorithms?

May 15, 2021

In a previous post, I rambled about the different meanings of the word algorithms. In the end, for me, the default meaning of the word is "the stuff that is taught in a standard undergraduate course in a computer science (CS) department." And then I shamelessly promoted my mini textbook.

Okay, if that's what algorithms is, then why should we learn it? To be concrete, let's say you've already decided to become a software engineer (or something similar). Why should you learn algorithms? Why is it required for the computer science degree? And why does it place so much emphasis on proofs? I'll outline my case below.

  1. They're a big part of computer science. I think most people don't realize that "computer science" refers to a huge array (heh) of areas. (I'm sure the same can be said for many other fields.) One major area in CS is theoretical computer science (TCS), which is basically the "math" that underlies the field. So I think it makes sense that CS majors should have a basic understanding of TCS, in the same way that a musician should have a basic understanding of music theory.

  2. They're directly useful (for interviews, on the job, and in life). At the very least, the interview for software-related jobs often requires knowing some algorithms. These tend to be a particular subset of algorithms, but nonetheless, taking a course is useful preparation. Furthermore, you never know when you might need an algorithm on the job. Even if you don't know the exact algorithm, having a general understanding and awareness of the field can guide you to a good solution. Finally, who knows? Maybe you'll have to sort a massive deck of cards someday.

  3. The exercises help improve one's ability to reason abstractly. The analogy I've heard is that working on exercises (e.g., ones you'll find in a textbook) is similar to a football player lifting weights. Although weightlifting isn't directly applicable to football since there are no barbells on the field, weightlifting is a systematic way to improve one's physical strength, which does matter on the field. Similarly, algorithms exercises provide a closed environment, with known solutions, to help students improve their "mental strength." This enables clearer thinking when faced with a messy, abstract problem outside the classroom.

  4. Proofs are good writing practice. Nearly all careers involve written communication, through emails, slideshows, reports, etc. And when we write in these settings, we should strive to be clear and concise. Writing formal mathematical proofs is good practice for achieving this. Ideally, your algorithms instructor provides feedback on your writing, and receiving writing feedback is valuable because it doesn't occur as often in non-academic settings. (Unfortunately, graders often don't have time and/or expertise to provide good feedback.)

  5. It's intellectually stimulating and satisfying. This one's hard to believe when you're worried about an interview or exam, but I think it's true: learning is fun! There are generally three parts to a problem in algorithms: figuring out the solution, looking it up (possibly), and understanding why it works. Taken together, these steps scratch a mental itch that I find hard to scratch otherwise. Moreover, there's something nice about knowing how to solve any instance of simple mathematical problems. Which route should I take to get to my destination? Which items should I pack to maximize the total value? These are natural-sounding problems, so it's satisfying to learn how to solve them.

Hopefully you found this convincing, and now you're slightly more motivated to learn more algorithms (or study for the class you're currently taking). Of course, I can't guarantee anything about your experience, but feel free to tell me about it.