Unit 2 - Activity 5 - Pseudocodes Algorithm Flowcharts and Dry Runs Reading
Unit 2 - Activity 5 - Pseudocodes Algorithm Flowcharts and Dry Runs Reading
Algorithm
Flowcharts
Dry runs
READING
1
Topics of discussion:
Control flow.
Design Methodologies ! (Pseudocodes, Algos, Flowcharts)
Dry runs!
How are they interlinked?
Practical life implementation!
Bibliography.
2
Control flow:
Sequence: Selection: Iteration:(repetition)
Action 1 If <condition> then Loop for n times
Action 2 <action> end if Action(s) to be carried out
Action 3 ----------------------------------- Repeat
---------------------------------- If <condition> then -----------------------------------
Action 1 <first action> Loop while a condition
Action 1a Else exists
Action 1b <second action> Action(s) to be carried out
Action 2 End if Repeat
---------------------------------- ---------------------------------- and
Action 1 If <condition> then Repeat
Action 1a <first action> Action(s) to be carried out
Action 1a(i) Else if <condition> Loop while a condition
<second action> exists.
Action 1b(ii)
Action 3 End if
3
Design Methodologies!
?Pseudocodes
(Examples)
Algorithms
(Example)
Flowcharts
(Example)
4
Pseudocodes!
Also known as” Program Design Language” (PDL) or structured English,
pseudocodes are used to express program design verbally rather than
diagrammatically.They were originally developed by assembly language
programmers.
Features:
?Uses only 3 structures: sequence, selection and repetition.
?Translates design to implementation in the programming.
?Statements are in simple English but they can be complex.
Advantages:
?Freedom of native Language.
?No syntax problems.
?Can be easily generated and maintained by any software.
?Involves much less time and effort than drawing any other equivalent designing method.
5
Pseudocodes! ( Examples)
6
Algorithms!
An algorithm is a series of instructions or steps for the solution of a problem.
This is made up of three main type of components:Sequence, selection and
repetition.
A sub-algorithm is a complete and independently defined algorithmic
module which is used by some main algorithm or sub-algorithm.
An algorithm broken down into more and more detailed steps is shown by
“structural diagrams”. In this:
Sequence is shown by writing the brief statement in the rectangles joined
by lines across the page from left to right.
Selection by drawing a small circle in the top right of each choices and
writing the condition for selecting that box just above it.
Repetition is shown by drawing an asterisk in the top right of the step being
repeated and writing the condition for repeating just above it.
7
Certain conventions are used in presenting an algorithm:
? Steps: The steps of an algorithm are executed one after the other.
? Control: The control is transferred when the steps are executed one by one.
? Exit: The algorithm is completed when the statement is encountered.
? Comments: Comments in the brackets indicates the main purpose of the step.
? Variable Names: Variables names as counters and subscripts uses capital letters.
? Assignment statements: These are used to assign the values to the variables by using
the ”=“ (equal to) sign.
? Input and Output: Write statements are used to input the values and Read
statements are used to get the output values
8
Algorithms! (Example)
9
Flowcharts!
Flowchart is a pictorial representation consisting of labeled geometrical symbols
together with arrows connecting one symbol to another.It consists of a combination
of:
? Symbols: to represent the operations.
? Messages in symbols: to explain briefly what operations are.
? Arrows: that connect the symbols.
Advantages:
? Its assists the programmer when he actually starts to writes the program.
? Much easier to understand.
? The programmer understands what has to be done to produce the desired results.
? Correction and modification becomes a lot easier.
10
Limitations:
?Time consuming and laborious to draw.
?Proper symbols and spacing must be carried out.
?There is no determination to the amount of details.
Rules of flowcharting:
?Details ought to be inputted after the lines of logic have been charted.
?Consisted level of details must be maintained.
?Not much details are required.
?Statements must be common, descriptive and easy to understand.
?Flow must be from left to right and from top to bottom.
?Flowchart must be very simple.
?Crossing of flow lines must be avoided.
?Labeled connectors must be use to break the flowchart and connect it at any input or
output.
11
There are five basic symbols of flowcharts:
Symbols Meaning
(oval) Terminal
(parallelogram) Input/Output
(rectangle) Process
(diamond) Decision
12
Symbols:
System Flowcharts: Programming Flowcharts:
13
Rules for drawing :
14
Examples:
Write Bonus
Students’
transcript
Stop
15
There are some soft wares that can help you create your flowcharts. They are:
16
Dry Runs!
The manual working through the system is known as dry run. It is a powerful tool to
clearly and concisely define the word statement in a tabular form.
Certain steps are to be followed while constructing the dry run table:
?Problem to be solved must be properly defined.
?All the conditions to be tested must be listed out.
?All corresponding actions should also be should be taken with each combination of
conditions.
Advantages:
?They are easier to draw and change.
?Programmer knows the outcome before the final implementation of the program, thus
errors on the program can be edited.
?A small table can replace several pages of flowcharts.
?It is also easier to follow a particular path down one column than through several
flowchart pages.
17
Dry Runs (example)
Problem:
For the phrase “I LIKE COMPUTER STUDIES SENT”, set word count and char count to 0,
and read the next word. Until the word is “sent”, set length to number of characters in the
word and increase the char count by length and word count by one. Next set the average
to char count divided by word count and display the output.
2 5 4
3 13 8
4 20 7
5 24 4
18
How are they interlinked ?
The design methodologies and the dry runs are inter-related to each other:
To test the program, made by the above sources, without actually installing it
on the computer, is known as dry run.
19
Real-life implementation!
20
Bibliography.
Following are the sources that enabled us to create our presentation :
Computer Studies by Tony Rackham.
Computer Fundamentals by P.K.Sinha.
Data Structures by Seymour Lipschutz.
Data Processing by Seymour Lipschutz.
Introduction to Computer Studies by Peter Norton.
Also there was a great role of internet. The following sites helped us a lot:
www.flowcharting.com
www.smartdraw.com
21