Algorithm
and
Flowchart
Devyani Soni
Department of Computer Science & engineering
Contents
Algorithm
Advantage and Disadvantage of algorithm
Flowchart
Advantage and disadvantage of flowchart
Algorithm vs. flowchart
Algorithm
An algorithm is a step-by-step method to solve
problems. It includes a series of rules or instructions in
which the program will be executed.
Before writing an algorithm for a problem , one should
find out what are the inputs to the algorithm and
what are expected output after running the algorithm
Definition of algorithm
“An algorithm refers to a set of instructions that define the
execution of work to get the expected results.”
Example
Problem:
write an algorithm to read two numbers and find their sum.
Inputs to the algorithm:
First num A
Second num B
Expected Output:
Sum of two numbers C
Algorithm:
Step 1: start.
Step 2: Read\ input the first num A.
Step 3: read\ input the second num B.
Step 4: C= A+B // calculation of sum
Step 5: print C.
Step 6: End
Types of Algorithm
The algorithm classify into three control structure.
They are as:
1. Sequence
2. Branching(Selection)
3. Loop (repetition)
Advantage of algorithm
Algorithms are easy to write.
There is a use of human-readable techniques to
understand logic.
For big problems, algorithms can be written with
moderate steps
Disadvantage of Algorithm
Algorithms are difficult to debug.
It is hard to show branches and loops using an
algorithm.
Jumping (or goto statements) makes the algorithm hard
to trace the problems.
Flowchart
The Flowchart is the most widely used graphical
representation of an algorithm and procedural design
workflows.
This means by seeing a flowchart one can know the
operation s performed and the sequence of these
operations in a system.
It uses various symbols to show the operations and
decisions to be followed in a program. It flows in
sequential order.
Flowchart format
There are basic 6 symbol used in flowchart
symbol name
Function
process
Input/
output
desicion
symbol name
Function
connectors
Predefined process
Terminal
Flow lines
Rules for flowcharting
1. All boxes of the flowchart are connected with
arrow.
2. Flowchart symbols have an entry point on the top
of the symbol with no other entry point. The exit
point for all flowchart symbols is on the bottom
except for the decision symbol.
3. The decision symbol has two exit points; these can
be on side or bottom and one side.
4. A flowchart will flow from top to bottom.\
5. Connectors are used to connect breaks in the
flowchart.
6. Subroutines and interrupts program have their
own and independent flowchart.
7. All flowchart start with a terminal or predefined
process.
Example
Problem : sum of two numbers
start
Read A, B
C=A+B
Print c
end
Difference between
Algorithm and Flowchart
S. No Algorithm Flowchart
A flowchart is a diagram
An algorithm is a step-by-
created with different
1. step procedure to solve a
shapes to show the flow of
problem.
data.
The algorithm is complex to A flowchart is easy to
2.
understand. understand.
In the algorithm, plain text is In the flowchart,
3.
used. symbols/shapes are used.
The algorithm is easy to
4. A flowchart is hard to debug.
debug.
The algorithm is difficult to A flowchart is simple to
5.
construct. construct.
The algorithm does not The flowchart follows rules
6.
follow any rules. to be constructed.
A flowchart is just a
The algorithm is the pseudo-
7. graphical representation of
code for the program.
that logic.
End