⚫Did you know that for
every task that is carried
out on a computer,a
program must be written
for it and all programs are
written from algorithms?
1
IMPORTANT FACT
⚫COMPUTERS CAN ONLY DO EXACTLY WHAT THEY ARE
INSTRUCTED TO DO, HENCE WE HAVE TO BE VERY
PRECISE WHEN PLANNING THE SOLUTION TO A PROBLEM
THAT WILL PROGRAMMED INTO A COMPUTER SYSTEM.
⚫IT IS THEREFORE IMPORTANT THAT YOU ANALYZE A
PROBLEM AND DEVELOP ITS SOLUTION ON PAPER
BEFORE YOU START PROGRAMMING.
2
The design of any computer program
involves two major phases:
⚫The Problem- Solving Phase
⚫The Implementation Phase
3
PROBLEM SOLVING
step-by-step process that always proceeds in a
linear and logical manner.
4
OBJECTIVES
⚫OUTLINE THE STEPS OF THE COMPUTER BASED
PROBLEM SOLVING PROCESS
⚫ANALYZE A PROBLEM AND RECOGNISE ITS PARTS
⚫CREATE IPO CHARTS/DEFINING DIAGRAMS
5
THE PROBLEM SOLVING
PROCESS
⚫Identification and definition of the Problem
⚫Problem Analysis
⚫Identification and evaluation of possible
solutions
⚫Selecting and justifying the optimal solution
⚫Represent the most efficient solution as an
algorithm
⚫Test and validate the algorithm for correctness
6
step 1- DEFINE THE PROBLEM
⚫Most important step- leads to a clearer
understanding of what is given & what is
required
⚫Look at problem carefully and if it is not
phrased properly you should modify that to
make sure that it is clearly stated.
⚫Problem must be written clearly with as many
important details as possible
7
Are these problem
statements clear and
complete?
⚫Find the area of a shape
⚫Calculate the discount
⚫Calculate the average temperature
⚫Add the heights of three students and find the average
⚫Calculate the price
8
Step 2- ANALYZE THE
PROBLEM
⚫Break up the problem into smaller problem or sub
problem: top-down design
⚫Identify the inputs to be used
⚫Identify the outputs required
⚫Identify values to be stored(if any)
⚫Identify the processing that needs to be done to get the
correct output
⚫Create a defining diagram
9
INPUT
⚫Input- data that you will need in order to calculate or solve a
problem
⚫ENTER THE PRICES OF THREE ITEMS
Words such as enter, read , input, get
10
PROCESSING
⚫ PROCESSING- what must be done to solve the problem
ADD THE WEIGHT OF 2 STUDENTS
⚫Words such as calculate, work out, find
11
OUTPUT
⚫End result or solution you require
⚫DISPLAY THE SUM OF TWO NUMBERS
Words such as print, display, show, output
12
Defining diagram/IPO chart
⚫This is a table with three columns which represent
the three components:
⚫ Input-source data
⚫ Output-end result
⚫ Processing-list of actions to be performed to achieve required
output
INPUT PROCESSING OUTPUT
3 numbers Read three numbers total
Add numbers
Print total
13
QUESTION?????
⚫Get 2 numbers, add them
together and display their
sum
14
SOLUTION/ipo chart
INPUT PROCESSING OUTPUT
Two numbers Accept two numbers sum
Add the numbers
Store results
Display the result
15
Step 3-IDENTIFY & EVALUATE POSSIBLE SOLUTIONS
⚫Alternative solutions must be acceptable ones
⚫List should be as complete as possible
⚫Identify and evaluate the pros and cons of each possible
solution
16
step 4-
SELECT AND JUSTIFY THE
OPTIMAL SOLUTION
⚫Choose the solution with more pros than cons
17
Step 5- DEVELOP AND
REPRESENT AN ALGORITHM
⚫AN ALGORITHM IS -Finite number of accurate,
unambiguous steps that solve a problem or
task
START
Read Num1, Num2
Sum = Num1 + Num2
Print Sum
STOP
18
Step 6-TEST AND VALIDATE
THE ALGORITHM
⚫Check the algorithm you wrote using some values to
ensure that it produces the required results
19