Problem -> analysis -> solution: an algorithm. An algorithm describes the sequence of steps to be taken to solve a problem. It can be expressed as text, flowchart, or program pseudocode. Finally, it is coded (programmed) using a programming language.
In this exercise, we first learn to describe problem solutions as flowcharts. Then we design some simple program algorithms. We don't learn any particular programming language syntax yet but this design method can be used in connection with almost any programming language.
Common flowchart symbols:
Two examples of flowcharts: a conditional
statement (if) and a (repetitive) loop:
More examples about flowcharts and the whole of David Beech's Programming course (published with the permission of the author).
Example algorithm 1. Give advice how to choose a pet.
Select one of the following problems and create a solution as a flow chart. Use Microsoft Visio (Powerpoint, or Jude) to make the drawing. You can do this in a small team. Test it by walking through the procedure. Is it Ok or does it need developing?
Practice 1a. Make a flowchart that helps a visitor to Metropolia find his way home from Leppävaara.
Practice 1b. Describe the process of preparing a party as a flowchart.
Practice 1c: Design a procedure to help a smoker stop smoking.
Practice 1d: Make a flowchart how to advice people to choose a university/ profession.
Alternatively, you can hand in a solution to the pet problem, or draw a flowchart of a small procedure: what happens in the computer when a desktop icon is clicked to start a Word processing program?.
One solution for exam results looks like this, with calculation separated from the printing of results:
Set total as 0.
Ask the number of students.
Create a table for student scores, names and grades.
Start the procedure for students. Are there any students left?
No: go to result.
Yes: Ask the name and the score.
Calculate the grade:
Is the score less than 10?
Yes: student failed. Write grade as 0. Go to totals.
No: Is the score less than 20?
Yes: Write grade as 1. Go to totals.
No: Write grade as 2. Go to totals.
Totals: add grade to total.
Add one to the student number.
Take next student.
Result: divide total by number of students.
Print "average is " result.
Print the list of students and grades.
Think what kind of flowchart the above results in (something like main, process1, process2).
|Created by: Jaana Holvikivi Updated: 28.11.2012|