Problem Solving
Problem Solving
We will learn
1.
2.
Problem Statement.
Algorithm
Types, Example
Flowchart
Symbols, Examples.
3.
Problem Solving
Techniques
Problem Statement:
Problem Statement help diagnose the situation so that
your focus is on the problem, helpful tools at this stage
include Algorithms and flowcharts for identifying the
expected steps of a process. Therefore to solve any
problem,
Algorithm:
The algorithm is part of the blueprint or plan for the
computer program, an algorithm is:
An effective procedure for solving a class of problems
in a finite number of steps.
Every algorithm should have the following 5
characteristic feature:
1.
2.
3.
4.
5.
Input
Output
Definiteness
Effectiveness
Termination
Algorithm (Contd):
1)
2)
3)
4)
5)
6)
Algorithm (Contd):
Example: One of the simplest algorithms is to find the
largest number in an (unsorted) list of numbers.
High-level description:
1)
2)
3)
Algorithm (Contd):
Formal description: Written in prose but much closer to
the high-level language of a computer program, the
following is the more formal coding of the algorithm in
pseudo code (find the largest number in an
(unsorted) list of numbers)
Algorithm LargestNumber
Input: A non-empty list of numbers L.
Output: The largest number in the list L.
1)
2)
3)
4)
Flowchart:
What is a Flowchart?
Flowchart (Contd):
Guideline for drawing a flowchart:
Flowcharts are usually drawn using some standard
symbols; Some standard symbols, which are frequently
required for flowcharting many computer programs are
shown below,-
Flowchart (Contd):
A set of useful standard Flowchart
symbols:
Rounded box
use it to represent an event which occurs automatically.
Rectangle or box
use it to represent an event which is controlled within the
process. Typically this will be a step or action which is
taken.
Diamond
use it to represent a decision point in the process.
Circle
use it to represent a point at which the flowchart connects
with another process.
ADVANTAGES OF USING
FLOWCHARTS:
ADVANTAGES OF USING
FLOWCHARTS (Contd):
Flowchart (Example):
Flowchart to find the sum of first 50 natural numbers.
Read A, B
Yes
Is A > B
No
Print B
Print A
End
NO
LIMITATIONS OF USING
FLOWCHARTS:
Flowchart (Exercise):
1.
2.