“Introduction to
Algorithms & Flowcharts”
Problem Solving with Computers
• A knowledge of using and programming computers is essential for
scientists and engineers.
• The strength of the computer lies in its ability to manipulate and store
data.
Steps involved in Problem Solving with
Computers
1.Clearly define the problem.
2. Analyze the problem and formulate a method to solve it.
3. Describe the solution in the form of an algorithm.
4. Draw a flowchart of the algorithm.
5. Write the computer program.
6. Compile and run the program.
7. Test the program (debugging).
8. Interpretation of results.
ALGORITHMS (Definition)
• An algorithm present step by step instructions required to solve any
problem.
• It may be written in a non-formal language and structure.
Example of Algorithm
AddNum (c, a, b)
1. START
2. READ a and b
3. Compute c = a + b
4. Write c
5. END
Where a, b and c are real numbers
Qualities of a Good Algorithm
• Inputs and outputs should be defined precisely.
• Each steps in algorithm should be clear and unambiguous.
• Algorithm should be most effective among many different ways to
solve a problem.
• An algorithm should not have computer code. Instead, the algorithm
should be written in such a way that, it can be used in similar
programming languages.
FLOW CHARTS
• A flow chart gives the logical flow of the solution in a diagrammatic
form, and provides a plan from which the computer program can be
written.
• The logical flow of an algorithm can be seen by tracing through the
flowchart.
ALGORITHMS
ALGORITHM (Definition)
The algorithm gives a step-by-step description of the
solution.
It may be written in a non-formal language and structure.
Example of Algorithm
ALGO AddNums (c, a, b)
1. START
2. READ a and b
3. Compute c = a + b
4. Write c
5. END
Where a, b and c are real numbers
Qualities of a Good Algorithm
Inputs and outputs should be defined precisely.
Each steps in algorithm should be clear and unambiguous.
Algorithm should be most effective among many different ways to solve a problem.
An algorithm should not have computer code. Instead, the algorithm should be written in
such a way that, it can be used in similar programming languages.
FLOW CHARTS
FLOW CHART (Definition)
A flow chart gives the logical flow of the solution in a
diagrammatic form, and provides a plan from which
the computer program can be written.
The logical flow of an algorithm can be seen by tracing
through the flowchart.
Standard Flowchart Symbols
OVAL
An oval is used to indicate the beginning
Standard Flowchart Symbols
PARALLELOGRAM
A parallelogram indicates the input or output of information.
Standard Flowchart Symbols
RECTANGLE
A rectangle indicates a computation, with the result of the computation assigned to a variable.
Standard Flowchart Symbols
DIAMOND
A diamond indicates a point where a decision is made.
Standard Flowchart Symbols
ARROW
An arrow indicates the direction of flow of algorithm.
EXERCISES
EXERCISE - 01
Consider the problem of finding the sum, average and
product of 3 numbers given by the user.
EXERCISE – 01 (Algorithm):
Read X, Y, Z
Compute Sum (S) as X + Y + Z
Compute Average (A) as S / 3
Compute Product (P) as X x Y x Z
Write S, A and P
EXERCISE – 01 (Flow Chart):
EXERCISE - 02
Consider another problem of finding the largest number
between A and B
EXERCISE – 02 (Algorithm):
Read A, B
If A is less than B
BIG=B
SMALL = A
Else
BIG=A
SMALL = B
Write (Display) BIG, SMALL
EXERCISE – 02 (Flow Chart):
THANK YOU!