Monday, July 16, 2012

What is an Algorithm


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.

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"?)
·        It is in the correct sequence.
·        Is very specific to the task at hand.

2.      Define Algorithms for the following processes.

Posting a letter:
1. write the letter on piece of paper.
2. put letter into the envelope.
3. seal envelope
4. write the address of the person you are sending the letter to on the front 
5. stick stamp onto the right top hand corner of envelope
6. write your address onto the back of the envelope
7. walk to post office or post box
8. drop letter into the post office /post box 

Making Toast: 
1. get bread
2. go to toaster 
3. put bread into toaster
4. press leaver on toaster to push toast down
5. wait 2-3 minutes until toast pops up again 
6. take bread out of toaster
7. put desired topping onto toast 

Calling a friend on the cordless land line phone: 
1. Pick up the phone 
2. Dial the number into the phone 
3. Press the green call button
4. Wait for call to connect and the person to pick up 
5. If person doesn't answer the phone repeat steps 1-4 if person doesn't answer
6. Talk to the person

No comments:

Post a Comment