An algorithm is an unambiguous set of steps, which when performed correctly by a processor, will result in a process being carried out in a finite time.
EXAMPLE: if you were to explain to someone how to make a cup of coffee you would be defining an algorithm;
1. boil the water,
2. place coffee in the cup,
3. place sugar in the cup,
4. add the boiling water,
5. add milk,
6. stir.
1. Examine the algorithm above. What two properties of the algorithm enable it to correctly describe the solution to the problem of making a cup of coffee? What is it that makes an algorithm correct?(Hint: what would happen if you swapped step "6" and step "2"?)
- The first property that is vital in an algorithm is that the processes are in order. Any change of order will alter the ultimate outcome. Suppose you swapped step 6 and step 2, the algorithm would look like this:
1. boil the water,
6. stir.
3. place sugar in the cup,
4. add the boiling water,
5. add milk,
2. place coffee in the cup
Here you would actually be stirring nothing in the second step and placing coffee in cup at the end. Therefore the steps and their order are essential to an algorithm.
- The scond property, i believe, is that they have to conscie, clear and to the point. Too many complicated words will not only complicate your task but also the readers or the information process system.
- POSTING A LETTER:
1. Write the letter
2. Place the letter in an envelope
3. Put the envelope in the post box
- MAKING TOAST
1. Get the bread out
2. Set up the toaster
3. Put the toast in the toaster
- CALLING A FRIEND ON THE PHONE
1. Get the phone
2. Find your friends number
3. Dial that number
4. Call
No comments:
Post a Comment