0% found this document useful (0 votes)
1 views21 pages

Unit 2 - Activity 5 - Pseudocodes Algorithm Flowcharts and Dry Runs Reading

The document discusses control flow, design methodologies such as pseudocodes, algorithms, and flowcharts, and their interconnections. It explains the advantages and limitations of each method, along with examples and rules for their application. Additionally, it covers the concept of dry runs as a testing method and provides a bibliography of sources used for the presentation.

Uploaded by

anhadsangha903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views21 pages

Unit 2 - Activity 5 - Pseudocodes Algorithm Flowcharts and Dry Runs Reading

The document discusses control flow, design methodologies such as pseudocodes, algorithms, and flowcharts, and their interconnections. It explains the advantages and limitations of each method, along with examples and rules for their application. Additionally, it covers the concept of dry runs as a testing method and provides a bibliography of sources used for the presentation.

Uploaded by

anhadsangha903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Pseudocodes

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)

Sequence: Selection: Iteration:(repetition)

Fill the kettle with water If age<18 then Set total to 0


print “Too Young ! ”
Take kettle to tap Else Loop for 15 times
Remove lid if age>65 get next number
Turn tap on add number to total
Wait until full print “Too Old ! ” Repeat
Turn tap off Else
Replace lid print “ O.K. “ Print total
Return kettle End if

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

The sequence of instructions of an algorithm must possess certain characteristics:


? Each and every instruction should be precise and unambiguous.
? Each instruction should be performed in a finite time.
? One or more instructions should not be repeated infinitely.
? After performing the instructions the desired result must be obtained.

8
Algorithms! (Example)

Given a non-empty array DATA with N numerical values, this algorithm


finds the location LOC and the value MAX of the largest element of DATA.

Step 1: Set k=1, Loc=1, max=Data[1]


Step 2: Repeat step 3 and step 4 while K<=N
Step 3: If Max<Data [K] then
Set Loc=K and Max=Data [K]
End of if
Step 4: Set K=k=1
End of loop
Step 5: Write Loc,Max
Step 6: Exit.

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

(small circle) Connector

(rectangle) Process

(diamond) Decision

There are two completely different types of flowcharts:


? System flowcharts : These represent the operation on data in the system.
? Programming flowcharts : These represent the sequence of operations.

12
Symbols:
System Flowcharts: Programming Flowcharts:

13
Rules for drawing :

System Flowcharts: Programming Flowcharts:


? Lines and arrows must show the flow ? Flow lines must be either in a
of data and not necessarily the order. horizontal or vertical direction.
? Start and stop symbols as well as ?Arrows must be used to make the
decision boxes are not to be drawn. direction of the flow clear.
? A system flowchart should not show ? Only one line must go into a box.
details of how computer program works. ? Ordinary English must be used where
? Program should be presented in possible.
process boxes in order down the middle ? Additional notes must be used must
of the page. be added in right hand margin, if
? Data collection and inputs should be at necessary.
the top left of the page. ? There must be just one entry point and
? Files and outputs must be on the right one exit point.
or left of the page. ? Vertical lines must show the flow down
? Annotations must be on the far right of the page, while horizontal lines must
the page. show it from left to right.

14
Examples:

System Flowcharts: Program Flowcharts:

Final exams Start

Graded by Postcards to Read Salary, Year


professor students

Registrar’s grade Bonus=0.03*Salary


sheet

Old New yes


master master Year>=10? Bonus = Bonus+100
Updates students’
file master file file
no

Write Bonus
Students’
transcript

Stop

15
There are some soft wares that can help you create your flowcharts. They are:

? Mac Flow 5.0.1


? Win .Flow 5.0.1
? Smart Draw.

These soft wares are:

? More powerful than ever.


? Easier to use.
? Improved interface.

Main new functions:


? Save your flowcharts as HTML.
? File-level compatible between the Macintosh and Windows platforms.
? New line functions that automatically draw overpass and tunnels.
? Use digital images as flowchart symbols.
? Customize your symbol palette with drag and drop.

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.

Word count Char count Length Average


1 1 1 24 / 5 = 4.8

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:

From the definitions of algorithms, flowcharts and pseudocodes we see that


they are the same things with minor difference. Algorithm is the technical
written form of pseudocodes while flowcharts are the graphical application of
algorithms.

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

You might also like