Class 5 - Problem Solving Techniques

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Algorithm

• A set of sequential steps usually written in ordinary language to solve a given problem is
called Algorithm.
• Steps involved in algorithm development:
Step1. Identification of input: There are quantities to be supplied called input and these are fed externally. The
input is to be identified first for any specified problem.
Step2: Identification of output: From an algorithm, at least one quantity is produced, called for any specified
problem.
Step3 : Identification the processing operations: All the calculations to be performed in order to lead to output
from the input are to be identified in an orderly manner.
Step4 : Processing Definiteness: The instructions composing the algorithm must be clear and there should not
be any ambiguity in them.
Step5 : Processing Finiteness: If we go through the algorithm, then for all cases, the algorithm should terminate
after a finite number of steps.
Step6 : Possessing Effectiveness: The instructions in the algorithm must be sufficiently basic and in practice
they can be carries out easily.
Algorithm
• Write an algorithm to calculate the simple interest using the formula-
Simple interest = P*N* R/100.

Step 1: Start.
Step 2: Read the three input quantities P, N and R.
Step 3: Calculate simple interest as Simple interest = P* N* R/100.
Step 4: Print simple interest.
Step 5: Stop.
Algorithm
• Write an algorithm to find the largest of three numbers X, Y, Z.

Step 1: Start.
Step 2: Read the numbers X, Y, Z.
Step 3: if (X > Y)
Big = X
else BIG = Y
Step 4 : if (BIG < Z).
Step 5: Big = Z.
Step 6: Print the largest number i.e. Big.
Step 7: Stop.
Flowchart
• A flow chart is a step by step diagrammatic representation of the logic paths to solve a
given problem.
• Flowcharts are usually drawn using some standard symbols.
Start or end of the program

Computational steps or processing function of a program

Input or output operation

Decision making and branching

Connector or joining of two parts of program

Off-page connector

Flow line
Flowchart

The following are some guidelines in flowcharting:


1. In drawing a proper flow chart, all necessary requirements should be listed out
in logical order.
2. The flowchart should be clear, neat and easy to follow.
3. The usual direction of the flow of a procedure or system is from left to right or
top to bottom.
4. Only one flow line should come out from a process symbol.
5. Only one flow line should enter a decision symbol, but two or three flow lines,
one for each possible answer, should leave the decision symbol.
6. Only one flow line is used in conjunction with terminal symbol.
7. Avoid the intersection of flow lines.
8. Ensure that the flowchart has a logical start and finish.
Differences Between Algorithm and Flowchart

The following are some guidelines in flowcharting:

Flowchart Algorithm

A flowchart is a diagrammatic way of It is a set of instruction or step by step


representing an algorithm. procedure to solve a problem.

The flowchart employs a series of blocks It contains step-by-step English


and arrows, each of which represents a descriptions, each step representing .
particular step in an algorithm.

It is very easy to create and understand. It is sometimes very difficult to create and
understand.

For complex programs, flowcharts For complex programs, algorithms prove


prove to be adequate to be inadequate
Pseudo Code
• The Pseudo code is neither an algorithm nor a program.
• It is an abstract form of a program.
• It consists of English like statements which perform the specific operations.
• It does not use any graphical representation.
• In pseudo code, the program is represented in terms of words and phrases, but
the syntax of program is not strictly followed.
• Example: Write a pseudo code to perform the basic arithmetic operations.

Read n1, n2
Sum = n1 + n2
Diff = n1 – n2
Mult = n1 * n2
Quot = n1/n2
Print sum, diff, mult, quot
End.

You might also like