You are on page 1of 14

ALGORITHMS

 The term Algorithm refers for the


logic of a program. it is the step by
step description of how to arrive at a
solution to the given problem
 It is defined as a sequence of
instructions that when executed in
the specified sequence, the desired
results are obtained.
Instructions

 Each instruction should be precise and


unambiguous.
 Each instruction should be executed in a
finite time.
 One or more instructions should not
repeated infinitely. This ensures that the
algorithm will ultimately terminated.
 After executing the instruction , the
desired results are obtained.
Example
of algorithm
 Fifty students in a class appeared in
their final exam. The division column
of their mark sheets contains the
division (first, second, third or fail)
obtained by them. If their marks
sheets are available with you, write
an algorithm to calculate and print
the total number of students who
passed in first division.
Solution:

 Step1: initialize total_first_division and


total_marks_sheets_checked to zero.
 Step2: take the mark sheet of the next student.
 Step3: check the division column of the mark
sheet to see if it is First. If NO , go to step 5
 Step4: Add 1 to total_first_division
 Step5: Add 1 to total mark_sheets_checked.
 Step6: is total_marks_sheets_checked=50?if no,
go to step 2.
 Step7: print total_first_division.
 Step8: stop.
Contd.

Purpose of algorithms:
Programmers design such algorithms
to solve complex programming
problems.
The example shows clearly that even
for every simple problem the
development of the algorithms is not
as simple as it might initially appears
and requires some thinking.
Representation of the algorithms
These are the various ways to
represent an algorithm . the
commonly used one are:
 As programs

 As flowcharts

 As Pseudo codes
Flow Chart
What is it?
- A picture of any process
- Drawn with standard symbols
representing different
types of activities
- Different styles available:
- Deployment
- Process
Flow Chart
A flowchart is a type of diagram that
represents an algorithm or process,
showing the steps as boxes of
various kinds, and their order by
connecting these with arrows. This
diagrammatic representation can
give a step-by-step solution to a
given problem.
Yes No

Start Task Make a


Decision

Flow Lines
End of
Process
Flow
Chart
Example
Communication: Flowcharts are better way of
communicating the logic of a system to all
concerned
.Effective analysis: With the help of flowchart,
problem can be analysed in more effective way.
.Proper documentation: Program flowcharts serve
as a good program documentation, which is needed
for various purposes.
Jk
Efficient Coding: The flowcharts act as a guide
or blueprint during the systems analysis and
program development phase.
Proper Debugging: The flowchart helps in
debugging process.
Efficient Program Maintenance: The
maintenance of operating program becomes
easy with the help of flowchart. It helps the
programmer to put efforts more efficiently on
that part.
 Complex logic: Sometimes, the program logic is
quite complicated. In that case, flowchart becomes
complex and clumsy.
 Alterations and Modifications: If alterations are
required the flowchart may require re-drawing
completely.
 Reproduction: As the flowchart symbols cannot be
typed, reproduction of flowchart becomes a
problem.
 The essentials of what is done can easily be lost in
the technical details of how it is done.

You might also like