Are Algorithms Really Like a Recipe?

Photo by Germs on Unsplash

Are Algorithms Really Like a Recipe?

Digging deeper into definition before diving into algorithm types

If you've ever asked someone what a computer algorithm is, you might have been told that an algorithm is a sequence of steps, like a recipe. This is accurate. But understanding algorithms enough to appreciate and use them for creative problem solving requires we go deeper with the definition.

An algorithm is a sequence of steps, as many have been told. But to be an algorithm, a given series of actions must accept and process some input and deliver some output as a response. Additionally, an algorithm must be able to handle multiple different input values of a valid data type and consistently produce the expected correct production.

For an algorithm to be helpful, it should also be able to run to completion using as little processing time and computing memory as possible.

As with the number of available recipes for baking your favorite cookie, numerous algorithms exist for building programs. From experience, it can become overwhelming just looking at Google Search results for programming algorithms and trying to decide where to begin. However, it helps to understand different algorithms by what they do fundamentally. These categories, or types, provide commonalities that allow us to compare and contrast which algorithms are best for the programming task at hand.

In this series, I focus on five essential types of algorithms that are commonly referenced and used in everyday programming work. The categories are:

  1. Brute Force Algorithms
  2. Recursive Algorithms
  3. Sorting Algorithms
  4. Searching Algorithms
  5. Hashing Algorithms

With each algorithmic type, we'll look at specific algorithms within that category and walk through how to write them in pseudocode and Ruby. The goal is not to memorize any code or to force you into becoming a Rubyist. Instead, it is to help you and me to develop better familiarity and functional literacy using algorithms in our personal and professional programming.

Do you need to know and understand algorithms to be a software developer? That's debatable. But learning how and when to use these building blocks of software engineering indeed enables us to be more effective and efficient at writing and debugging complex programs. As a bonus, you might gain a greater appreciation for how everyday technologies work.

In the next article in this series, we look at the most basic type of algorithm. It's one you've certainly used whether you knew it or not: Brute Force algorithms.