Thursday, 6 August 2009

Selection and Repitition

Algorithm
-sequence
-selection
-repetition
Sometimes solving a problem involves making a decision between two or more options and this process is called
- Selection

In "plain English"
1. MOVING THROUGH A SET OF TRAFFIC LIGHTS

1. When u see traffic lights approaching
a) if its green, continue moving along, either going straight, left or right.
b) if its orange, [and you think its safe and you can make it, just speed up a little, * dont take any chances*]
c) if its red, slow down and stop before the line and wait until it turns green.
NOTE: Even if its green and orange and you are going, make sure to look out for any cars turning, left or right.

2. Deciding whether to take an umbrella to school

1. In the morning or the day before check the weather report for the next day.
a) if it says its going to rain, then pack your umbrella
b) if it says its going to be cloudy all day, then still pack your umbrella ( weather reports aren't always right)
c) if it says its going to be sunny in the morning and cloudy in the afternoon (or vice versa), still take your umbrella.
d) if it says its going to be a beautiful, sunny day then leave your umbrella at home, but make sure to check in the morning that it looks like a nice clear blue sky.

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

1.
a)Look at your marking criteria, if you have one and go according to that.
b)If it is a test like math
- 80%-90% ( A), [if their mark is like 78 or 79% be generous and give them an A, if they have done well in their other tests as well.]
- 60%-80% (B)
- 40%-50% (C)


Often an algorithm will often require you to repeat a task in order to solve a problem; when this is done in an algorithm the structure is called repetition.

In "plain English"
1.Adding the correct amount of cordial to water to make a drink

1. Get desired flavor cordial out.
2. Fill a glass ( or more) of cool water from the tap.
3. Get lid off the cordial
4. Place amount of cordial, about half a cup/more/less, whatever amount you desire.
Repeat all over, for how many cordial drinks you want.

2. Filling a bucket with water

1. Get bucket
2. Go into an area with a tap.
3. Place bucket underneath tap
4. On tap, not too high.
5. Stop until you are happy with amount of water
6. If too much water, tip water out.
7. If by mistake you have tipped too much water out refill water.
[Steps 6 and 7 repeat, until you are satisfied with the amount of water]

3. Blowing up a balloon.

1. Get balloon ( whatever color you want)
2. Blow into balloon, until you can't blow anymore.
3. If you want balloon bigger, keep blowing.
4. Until to you are happy with size of balloon, stop
Note: Dont make balloon to big, may just pop.
5. Tie up the end of balloon or let the air out.
[Repeat steps 2 and 3]

No comments:

Post a Comment