Algorithms
and
Flowcharts
TOPIC: Algorithms and Flow Charts
In this part of video we learn:
What is an algorithm?
Characteristics of algorithms.
General Structure followed to write an
algorithm.
How to write an algorithm with examples?
Algorithm
What is an algorithm?
A collection of finite number of sequential steps, when executed,
that performs a given task is known as algorithm.
It is step-by-step approach to solve a given problem.
It is represented in an English like language and has some
mathematical symbols.
Significance of algorithm
It is very much useful for writing Computer programs.
It acts as a blue print for writing programs
Characteristics of an Algorithms
Algorithm should satisfy the following criteria
(or) properties of algorithm :
1.Input :Zero or more quantities are externally
supplied.
2.Output :At least one quantity is produced.
3.Definiteness :Each instruction is clear and
unambiguous.
4.Finiteness :Algorithm should terminate after
finite number of steps when traced in all
cases
5.Effectiveness:Every instruction must be basic
i.e., it can be carried out, by a person
using pencil and paper.
General Structure followed or steps
choosen to write an algorithm
1.Start (Beginning of the Algorithm)
2.Input data (Read input if needed)
3.Computational steps( Evaluation of
expressions or decision making statement)
4.Output computed information (Display the
output)
5.Stop(Termination of the Program)
How to write an algorithm?
Example-1:
Find sum and average of three given numbers.
Title: Algorithm for sum and average.
Step-1: Start
Step-2: Read a,b,c
Step-3: Compute sum= a+b+c
Step-4: Compute average= (a+b+c)/3
Step-5: Print sum and average
Step-6: Stop
Example-2: Find largest of two given numbers.
Title: Algorithm largest of two given
numbers.
Step-1: Start
Step-2: Read a,b
Step-3: if a > b go to step-4 otherwise go to
step-5
Step-4: Print a is largest and go to step-6
Step-5: Print b is largest
Step-6: Stop
Merits and Demerits of Algorithm
Merits: Demerits:
Acts as a Blue print Time consuming.
for program Difficult to code for
development. lengthy problems.
Easy technique to Big tasks are
understand logic difficult to write in
Easy to identify an algorithm.
errors.
Easy to debug
Flowcharts
In this next part of the lesson we
learn
What is a flowchart?
Significance of flowcharts.
Flowchart symbols.
How to write flowcharts?
What is a flowchart?
A flowchart is a visual representation of the
sequence of steps followed for solving a problem.
(Or)
The diagrammatic or graphical or pictorial
representation of the way in which to solve a
given problem is called flow chart.
Flow charts are drawn using certain special purpose
symbols such as Rectangles, Diamonds, Ovals and
small circles. These symbols are connected by
arrows called flow lines.
Significance of Flowchart
Flowchart is an important aid in the
development of a solution to a problem.
Easier to Understand than an algorithm.
Independent of any particular programming
language.
Proper documentation.
Proper debugging.
Easy and Clear presentation.
Symbols used in Flowchart
Name Symbol Use in Flowchart
Oval Denotes the beginning or end of the program
Parallelogram Denotes an input operation
Rectangle Denotes a process to be carried out
e.g. addition, subtraction, division etc.
Diamond Denotes a decision (or branch) to be made.
The program should continue along one of
two routes. (e.g. IF/THEN/ELSE)
Hybrid Denotes an output operation
Flow line Denotes the direction of logic flow in the program
Flowchart for swapping of two give numbers
Fig : Flowchart for swapping two numbers.
Flowchart for finding the largest of three
given numbers
Fig : Flowchart for largest of three numbers.
Merits and demerits of flowchart
Merits : DeMerits :
Short and simple
Logical steps Not suitable where
Effective solution is long
communication Complicate things
Difficult to alter
Try to do it yourself now?
Design an Algorithm to find the smallest of
three numbers.
Design an Algorithm to find the area and
circumference of a circle.
Design a Flowchart to find the area and
perimeter of a rectangle.
Design a Flowchart to determine whether a
number is prime or not.
Thankyou