1.1 Algorithms

An algorithm is an ordered list of actions that describe how to perform a task or solve a problem. Algorithms are an essential concept in the study of computer science, but they are broadly applicable. A recipe for making bread is an algorithm, even though making bread has nothing to do with computers. The recipe describes what actions you must take, and the order in which you must take them if you want to end up with something that looks and tastes like bread. If you deviate from the algorithm, there’s a good chance you end up with something quite un-bread-like. Other examples of algorithms are:

• instructions for assembling a bookshelf
• steps to operate a coffee maker
• a list of things to do in case of a fire

One note of caution, however: not everything that looks like a list or a set of instructions meets the standard for being an algorithm. Many real-world problems have subtasks that can be performed in any order. For example, a recipe that consists only of a list of ingredients is not an algorithm because it does not specify the instructions for the ingredients. Instructions without an explicit order can fall short of being an algorithm. For instance, if you are assembling a table, it doesn't matter which of the four table legs you attach first. Humans are often pretty good at figuring out when this is the case, and therefore might omit an ordering. Still, if they do, then the result is not an algorithm. Note that this isn’t a bad thing! Recipes that list only ingredients and instructions that leave out irrelevant ordering can be perfectly useful. They’re just not algorithms.