Thursday, July 21, 2011

Algorithms

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.

 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"?)

Firstly they must be labelled in the correct order and second you must include every step in the process. An algorithm is correct when the steps of the process is in the right order eg. in step 6 of how to make a cup of cofee you can't start stiring unless you got the coffee mixture in their with the coffee in step 2
2. Define Algorithms for the following processes.
Posting a letter.

1. Get the materials needed such as pen, paper, envelope, stamp, other things included in letter
2. Write the letter with a pen and include other items you want included in the letter eg. photographs, money, etc.
3. Place the letter in an envelope.
4. Seal the envelope.
5. Write the details of the person your sending the letter to on the front of envelope
6. Place stamp in front of envelope
7. Go to post office.
8.Place envelope in the post box.

Making toast. Calling a friend on the phone

1. buy bread from store

2. buy toaster from store
3. buy topping from store
4.place bread in toaster
5. choose the setting for the toasting degree
6. press the toaster button down.
7. wait for the bread to toast.
8. take bread out of toaster after done toasting
9. place toast on plate
10. Put a topping on your toast
11. place toast in hand
12. open mouth
13. place toast in open mouth
14. close mouth.

15. chew
16 .repeat steps 12-15 until all consumed.
17. clean up.

Calling a friend on the phone

1. Get the phone

2. Find your friend's number in which your goning to call
3. Dial his/her number on the phone using the number buttons
4. Press the call button
5. Wait till he/she picks up the phone
6. Hold phone to ear to talk on the phone
7. Once done talking, press the end call button
8. Put the phone back



No comments:

Post a Comment