Sunday, July 15, 2012

Algorithms


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

What makes this algorithim above so effective is that it has simple commands that can be followed by a computer. Addtionally the steps are chronological, making the task easy to be carried out.

2. Define Algorithms for the following processes.
Posting a letter.

Get a piece of paper

Using a pen write what you want on the paper

Fold the paper in half

Open envelope

Place paper inside envelope

Put the flap down

Seal the envelope

Put address on the outside of envelope

Put postage stamp

Drop of in post office

Making toast.

Withdraw two slices of bread from loaf

Place bread pieces inside the toaster

Pull the lever down

Set the temperature, according to 1 2 3 4 5

Wait for the bread to come out

Spread desired topping on bread
Calling a friend on the phone

Pick up the phone

Place the designated number

Wait for dial

Start talking once you hear a voice on the other end



No comments:

Post a Comment