PROBLEM
S O LV I N G
Chap 4
Krish Info Tech
P ROBL EM S OLVI NG CYC LE
• Identify and analyse the problem.
• Find its solution and develop algorithm of the solution.
• Code the solution in a programming language.
• Test and debug the coded solution.
Finally implement and maintain it.
Krish Info Tech
4. Testing 1.Analysis
• Perform testing
• Analyse the probel
and debugging
3. Coding 2. Design
• Coding of the • Find solution and
solution develop algorithm
STEPS IN PROBLEM SOLVING CYCLE
Krish Info Tech
S UB -ST EPS OF PROB LE M SOLVI N G CYC L E
Analyse the Problem
• Understand the problem well
• Analyse the problem
Developing the Algorithm
• Think of possible solution
• Follow Modular Approach while designing most appropriate solution
• Identify operation for solution
Krish Info Tech
S UB -ST EPS OF PROB LE M SOLVI N G CYC L E
Coding
• Code program using appropriate control structures.
Testing and Debugging
• Test debug your program
• Complete your documentation.
Krish Info Tech
S UB -ST EPS OF PROB LE M SOLVI N G CYC L E
Implement and maintain
•Implement your code
•Maintain your program
Krish Info Tech
• The process of breaking down
a big or complex problem into
PROBLEM a set of smaller sub-
SO LV ING U SING process in order to
DECOMPOSITION understand a problem or
situation better, is known as
decomposition steps.
Krish Info Tech
D E C O M P O S I T I O N I N V O LV E S
Dividing a task into a sequence of Identifying elements or part of
subjects. a complex system.
Krish Info Tech
Big Problem
Part 1 Part 2
DECOMPOSITION of Problem of Problem
Sub- Sub- Sub- Sub-
Program 1 Program 2 Problem 3 Problem 4
Krish Info Tech
• Decomposing a problem into smaller
sub-programs
NEED FOR
is important because large problems
DECOMPOSITION are disproportionately harder to
solve than smaller problems.
Krish Info Tech
• The set of rules that defines
how a particular problem can
be solved in finite number of
DESIGNING steps is known as algorithm.
ALGORITHMS • An algorithm is composed of
a finite set of steps, each of
which may require one or
more operations.
Krish Info Tech
Precision — the steps are precisely stated or
defined.
Uniqueness — results of each step are uniquely
defined and only depend on the input and the
result of the preceding steps.
CHARACTERISTICS
Finiteness — the algorithm always stops after a
OF A GOOD finite number of steps.
ALGORITHM
Input — the algorithm receives some input.
Output — the algorithm produces some output.
Krish Info Tech
COMPONENTS OF AN ALGORITHM
• While writing an algorithm, it is required to clearly identify the following:
The input to be taken from the user
Processing or computation to be performed to get the desired result
The output desired by the user
Krish Info Tech
E X AM PL E - A LG O R I T H M TO FI ND S Q UAR E
OF A NUMBER
Step 1 Input a number and store it to num
Step 2 Compute num * num and store it in square
Step 3 Print square
Krish Info Tech
FLOW CHART
A flowchart is a visual representation
of an algorithm.
A flowchart is a diagram made up
of boxes, diamonds and other
shapes, connected by arrows.
Krish Info Tech
SYMBOLS
Symbols Functions Descriptions
Also called “Terminator”
Start/End symbol. It indicates where
the flow starts and ends.
Also called “Action
Symbol,” it represents a
Process
process, action, or a single
step.
Krish Info Tech
SYMBOLS
Symbols Functions Descriptions
A decision or branching point, usually a
yes/no or true/ false question is asked,
Decision
and based on the answer, the path gets
split into two branches.
Also called data symbol, this
Input/Output parallelogram shape is used to input or
output data
Connector to show order of flow between
Arrow
shapes.
Krish Info Tech
START
GET
A&B
FLOWCHART TO
ADD TWO NUMBERS C=A+B
PRINT C
STOP
Krish Info Tech
• Pseudocode is an informal
way of describing the steps of
a program's solution without
PSEUDOCODE using any strict programming
language syntax or underlying
technology considerations.
Krish Info Tech
EXAMPLE
If students's marks is greater than or equal to 50
display "Passed"
Else
display "Failed"
Krish Info Tech