Sunday, July 15, 2012

Flowchart Basics

http://nos.org/htm/basic2.htm

    What is a flowchart?
A flowchart is a visual way of representing the flow of data through an information processing system, the operations performed within the system and the sequence in which they were performed


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 enter a decision symbol, but two flow lines, one for each possible answer, should leave the decision symbol.


Only one flow line should come out from a process symbol.

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.

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

The order in which the tasks are set (sequence), selection and repitition.

2.      Define Algorithms for the following processes. 

Posting a letter.
1. Write a letter
2. fold the letter 3. enclose letter in envelope
4. write posting adress
5. stick on stamp
6. drive to postbox
7. place envelope in postbox


Making toast.
1. put toast in toaster
2. push down lever on toaster
3. wait for the toaster to pop
4. take toast out of toaster and put on plate
5. Butter toast with a knife
Calling a friend on the phone
 1. switch mobile phone on
2. go through contacts and find the required number
3. press 'voice call'
4. wait for the person to pick up the phone