Monday, July 25, 2011

Selection and repetition

Selection- Solving a problem often involves making a decision between two or more options. In an algorithm this process of making a decision is called selection.
Examples:
Moving through a set of traffic lights:
1. While driving along a road and come across a set of traffic lights.
2. If the green light is on, then continue driving as before.
3. If the yellow light is on, then begin to slow down and prepare to stop.
4. If the red light is on, then stop your vehicle immediately.

Deciding whether to take an umbrella to school.

1.Look outside of the house to determine the weather at that particular moment.
If:
- It is a sunny fine day, do not take an umbrella.
- It is a cloudy or rainy day take an umbrella with you.

Giving a student an A, B or C on their test.

Calculate the student's percentage of the score the student got on his test result.
If:
- the student got between 0 - 33.3% give them a C.
- the student got between 33.4 - 66.6% give them a B.
- the student got between 66.7 - 100% give them a A.

Repetition- Doing something again and again until you're satisfied, a set of repeated actions.


Examples:
 Filling a bucket with water.
1) Place bucket under tap.
2) Turn tap on.
3) Wait 0.5 minute:
If:
- 4/5 of bucket is filled close tap
- If 4/5 of bucket is not filled progress to step 4
4) Repeat step 3)until 4/5 of bucket is filled up.

Blowing up a balloon:
1. Take a balloon and blow air inside of it using your mouth.
2. Repeat blowing the balloon (blowing and stopping to gain air).
3. Stop blowing the balloon, press the open hole of the balloon to stop the air from escaping it and check if the balloon is the correct size you wanted.
4. Repeat until satisfied (until the balloon has been blown up to the correct size).
5. Tie a knot (or 2) at the opening of the balloon.







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



Tuesday, July 19, 2011

Flowchart symbols and logic

What is a flowchart?

The flowchart is a means of visually presenting the flow of data through an information processing systems, the operations performed within the system and the sequence in which they are performed.

Describe the basic flowchart symbols for;


With the decision making symbol (diamond) and the process symbol (rectangle), what are the rules for how many lines may enter and leave the symbol.

Only one flow line should come out from a process symbol
Only one flow line should enter a decision symbol, but two or three flow lines could leave as each flow line could be a possible answer

Study the sample flowcharts then create a flowchart for a coin toss where heads means Mary pays for the pizza and Tales means Bill pays.

Friday, July 1, 2011

assignment

i have uploaded my website on studentnet under student work in IST