Lesson 01: Introduction To Algorithms
Specification Points Addressed in this lesson:
- Use a systematic approach to problem solving and algorithm creation representing those algorithms using pseudo-code, program code and flowcharts.
- Explain simple algorithms in terms of their inputs, processing and outputs.
- Determine the purpose of simple algorithms.
Flowchart is a graphical representation of an algorithm, where each action (input, output, process, decision) is represented with a symbol and the symbols are joined by an arrow to show the direction that the path that the algorithm follows.
Here is a list of the six flowchart symbols, their name and what they are used for.
Flowcharts terminal symbol is used to start as well as end the diagrams. The following flowchart takes a number as a score from the user and prints “pass” if the score is 60 otherwise prints “fail”.
Use the following to guide you when drawing a flowchart:
- Always include the start and stop symbol when possible.
- parallelogram is used for both input and output, the context should make the distinction for example score is an input, but “Pass” and “Fail” are output.
- Decisions must always have to lines leaving, one for yes and one for no, these must be labelled.
In the following example, two subroutine calls are made namely playgame() and updateLeader(user, score).
Notice that the playgame() doesn’t take any arguments, therefore the brackets are empty, however the updateLeader(user, score) requires two arguments. Both of these subroutines can be further specified as a subprogram with it’s own flowchart and clearly labeled.