Thursday, July 21, 2011

Algorithms

What is an Algorithm? An unambiguous set of steps, which when performed correctly by a processor, will result in a process being carried out in a finite time.

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"?)
In order for the algorithm to work, you need all the correct steps like the above algorithm for making coffee. It is impossible for step 6 and step 2 to be swapped around because after adding the hot water there is nothing to stir and and if you add the coffee last it probably wouldn't dissolve as it hasn't been stirred and the sugar would also just sit at the bottom of the cup.
It any of the steps were put in order or missing you wouldn't come to the solution of mixing the coffee or being able to make one.


2. Define Algorithms for the following processes.




No comments:

Post a Comment