An algorithm is a series of steps that can be applied mechanically in order to obtain a certain result. In daily activities we encounter algorithms everywhere. We will give some examples:
1. The algorithm of making a phone call:
- pick up the phone
- waiting for the tone
- if there is no tone, one hangs up and picks up the phone again
- when there is a tone, one dials a number
We can see that the process of making a phone call can be described in precise terms, a person being able to follow all the steps mechanically.
2. The algorithm of cooking a certain dish:
-mixing the ingredients in certain proportions
-boiling/baking/frying the mix for a certain time interval
-adding other ingredients to the mix
-boiling/baking/frying again until the final product is obtained.
3. Solving a first degree equation (ax+b=0):
-reading a and b
-if a=0 then if b=0 then the equation has an infinity of solutions
if a=0 then if b differs from 0 the equation has no solutions
if a is not equal to 0 then the solution is -b/a.
An analysis of the steps leads us to some conclusions:
- in any algorithm we are given some data and we want to obtain a certain result
-in any algorithm we are dealing with objects; certain operations are permitted for each object
-in most cases the person who is making the algorithm differs from the one who is executing it
In this site we will deal with making algorithms that are executed by the computer.
Solving a problem:
1. identifying the given data and the requested data
2. making the algorithm that solves the problem
3. writing the algorithm in a programming language
4. testing the program and debugging it until it is working correctly
Features of an algorithm:
1. finitude = the property of an algorithm to end after a limited time
2. clarity = the property of an algorithm to be precisely described
3. generality = the property of an algorithm to solve an entire class of problems