Chapter-4
INTRODUCTION TO PROBLEM SOLVING
Steps for problem solving
Step 1 : Analysing the problem
Step 2: Developing an algorithm
Step 3 : Coding
Step4 : Testing and Debugging
Algorithm
An algorithm is a step-by-step procedure to solve a given problem.
NOTE:
• In order to write effective algorithms, we need to identify the input, the process to be followed and the
desired output.
•A good algorithm, which is precise, unique and finite, receives input and produces an output.
Characteristics of a good algorithm
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.
Finiteness — the algorithm always stops after a finite number of steps.
Input — the algorithm receives some input.
Output — the algorithm produces some output.
Pseudocode
Pseudocode is an informal way of describing the steps of a solution without using any programming
language.
Pseudocode for calculating area and perimeter of a rectangle.
INPUT length
INPUT breadth
COMPUTE Area = length * breadth
PRINT Area
COMPUTE Perimeter = 2 * (length + breadth)
PRINT Perimeter
Flowchart.
Flowchart is a graphical representation of an algorithm to solve a given problem.
Flowchart Symbols
Flowchart to display the sum of two numbers entered by users.
Flowchart to check whether a number is odd or even.
Flowchart to calculate area and perimeter of a rectangle.
Decomposition.
Breaking down a complex problem into sub problems is known as decomposition
***************************