Vous êtes sur la page 1sur 3

Information Technology

WAYS OF REPRESENTING ALGORITHMS


Algorithms can be represented in a variety of ways. We will examine 3 of them here :
1.
Narrative

narrative

2.

pseudocode

3.

flowcharts

This is the use of natural language and natural language rules to construct sentences and paragraphs which
describe the actions to take.
The advantages of a narrative are that
it can be applied outside of computing,
It can be understood by most persons and
It requires no special training to construct
The disadvantages of a narrative are that
it can be too verbose (too wordy)
It can be context-sensitive (interpretation varies depending on persons background and
experience)
Pseudocode
A type of structured English that is used to specify an algorithm.
The advantages of pseudocode are that
it is independent of a particular language so programmers of different languages can all understand
it
programmers do not have to worry about syntax
Lay people can help to determine the validity of the logic because it is not that difficult to
understand
The disadvantages of pseudocode are that
It is very detailed and so requires a high level of concentration to determine the overall logic
The loose standards means that one solution may be depicted in several different ways by different
persons
Note the following about writing pseudocode :

You should give your pseudocode a name and a brief description to indicate what it does
You should list all the variables used and what data type they are.
You must always have start and stop.

332389389

Use indentation to help depict the logic

The control structures are :


Sequencing
Input statements - use terms such as input, get, read
Output statements use terms such as display, print
Assignment statements
Storing a value in a variable e.g. limit 12
Performing a calculation e.g. sum sum + num1
Selection
IF THEN
ENDIF
IF THEN ELSE
ENDIF
Iteration
FOR loops
WHILE loops

Program Flowcharts
A diagrammatic representation of the sequence of steps needed to perform a task. They show the sequence
of operations, movements, decisions and storage activities within a system.
The advantage of flowcharts is that
it is easy to understand by persons at all levels because of the visual nature
The disadvantages of flowcharts are that
They can become large and unwieldy when the programs are long and complex
When alterations are required the flowchart will have to be completely redrawn.
Reproduction: As the flowchart symbols cannot be typed, production of flowcharts becomes a
complex exercise.
Note the following about drawing flowcharts :
o Flowcharts should have a title/label
o All flowcharts must have one start and one stop point
o Flow lines should run from top to bottom or left to right
o Flow lines should not cross
o Start symbols have only one flow line going out
o Stop symbols have one flow line going in
o Decision symbols should have one flow line going in and two coming out
o Most other symbols have one line going in and one coming out
o Symbols must have the operation written in them

332389389

Flow chart Symbols:

332389389

Vous aimerez peut-être aussi