8.1. Algorithms Introduction

Simply put, an algorithm is simply a set of step by step instructions for accomplishing some task. If you have every followed a recipe like the one below, you have followed an algorithm.

Chocolate Cream Pie
1. Heat milk, marshmallows and chocolate in 3-quart saucepan over low heat,
   stirring constantly, until chocolate and marshmallows are melted
   and blended.
2. Refrigerate about 20 minutes, stirring occasionally until mixture mounds
    slightly when dropped from a spoon.
3. Beat whipping cream in chilled small bowl with electric mixer on high
    speed until soft peaks form.
4. Fold chocolate mixture into whipped cream.
5. Pour into pie shell.
6. Refrigerate uncovered about 8 hours or until set.

As long as you understand the directions, you do not need to know much about cooking to follow the recipe - this is the power of algorithms. Once we have created an algorithm, we no longer need to think about the principles on which the algorithm is based. All you have to do is follow the directions. This means that algorithms are a way of capturing intelligence and sharing it with others. Once you have encoded the necessary intelligence to solve a problem in an algorithm, many people can use your algorithm without needing to become experts in a particular field.

Algorithms are especially important to computers because computers are really general purpose machines for solving problems. But in order for a computer to be useful, we must give it a problem to solve and a technique for solving the problem. Through the use of algorithms, we can make computers “intelligent” by programming them with various algorithms to solve problems. Because of their speed and accuracy, computers are well-suited for solving tedious problems such as searching for a name in a large telephone directory or adding a long column of numbers.

Algorithm Requirements

To be useful, an algorithm must meet certain requirements:

Materials on this page adapted from:
Online Interactive Modules for Teaching Computer Science by Osman Balci et al.