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.
For 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 order in which the instructions are written in and the words such as ‘boil’ and ‘add’ tell us exactly what to do enables it to correctly describe the solution to the problem of making a cup of coffee.  

2. Define Algorithms for the following processes.
Posting a letter.1. Go to the post-office
2. Get a stamp
3. Place it on the envelope that the letter is in.
4. Place the letter in the mail-box.

Making toast.
1. Take 2 pieces of bread.
2. Spread butter on the bread.
3. Add cheese (optional)
4. Place it in the toaster.
5. Take it out of the toaster when it is ready.


Calling a friend on the phone
1. Pick up the phone.
2.Press the talk or call button.
3. Dial your friend’s number.









No comments:

Post a Comment