# What is an algorithm?

10 minutes

Individual or Group

## Example: Baking a Cake

Consider the following recipe.

Ingredients:

- 2 cups sugar
- 1 and ¾ cups all-purpose flour
- ¾ cups coca
- 1½ teaspoons baking powder
- 1 teaspoon salt
- 2 eggs
- 1 cup milk
- ½ cup vegetable oil
- 2 teaspoons vanilla extract
- 1 cup boiling water

Instructions:

- Heat oven to 350 degree Fahrenheit
- Grease and flour two 9-inch round baking pans
- Stir together sugar, flour, cocoa, baking powder, baking soda and salt in large bowl.
- Add eggs, milk, oil, and vanilla.
- Beat on medium speed of mixer 2 minutes.
- Stir in boiling water (batter will be thin).
- Pour batter into prepared pans.
- Bake 30–35 minutes or until wooden pick inserted in center comes out clean.
- Cool 10 minutes.
- Remove from pans to wire racks.
- Cool completely.

Is the above description an algorithm? Remember that an algorithm is a description of how to perform a computation. Some characteristics of an algorithm are as follows.

- It can solve more than one specific problem (that is, one algorithm gives rise to many computations)
- It can solve different instances of a particular problem class
- It can be general, but must not be vague
- It gives correct results
- Most algorithms should terminate (but there are important exceptions)
- An algorithm must be expressible in a language that can be understood by the computer to execute it

Can this recipe can be used to produce multiple outcomes?

This recipe always produces the same kind of cake. Does this fact disqualifies it as an algorithm?

Where else would you see algorithms in the kitchen or at home? What is needed for an activity to qualify as an algorithm? Do you always need two lists (ingredients and instructions)?