Professional Documents
Culture Documents
Problem Solving Introduction Handout
Problem Solving Introduction Handout
PROBLEM-SOLVING
AND
PROGRAM DESIGN
HANDOUT
2
In our everyday life we actually solve simple problems. For example, you have a problem
meeting your deadlines.
2. Determine possible solutions to the problem such as: using reminders for the deadlines you
have to meet on your phone, work book etc, get your parents involved in reminding you
about your deadlines, completing the tasks you have to complete as soon as you get them etc.
3. The possible solutions you would then evaluate to determine the best solution to the
problem.
A computer program is a finite set of clear and specific instructions, written in a programming
language.
3
When faced with a complex problem, it is easier to break the problem down into smaller,
more manageable sections and tackle each section as a separate entity, rather than trying to
solve the large problem in one go.
4
Let’s assume you were creating a program to simulate the basic operations of a calculator.
Below is a diagram depicting the divide and conquer concept.
Major Problem:
Performing basic
Calculator
Calculations
As you may observe with the diagram above, there is a Major Problem which has been broken
down into four sub-tasks. Each sub-task may have specified action(s) that will be carried out to
solve the overall problem.
Defining the problem is a way to help the programmer understand what he or she is required to
do. It involves breaking down the problem into three key components:
These three components can be illustrated using what is a called a defining diagram. Some text
may refer to this as the Input Processing and Output (IPO) chart. The defining diagram is a
formal approach to defining a problem. The defining diagram is a table with three columns,
which represents the three components: input, processing and output.
5
The Input
The input is the source data provided. You can identify what is the input in a given problem by
the following keywords: given, get, read or accept.
The Output
The output is the end result required. You can identify what is the output in a given problem by
the following keywords: print, display and output.
The Processing
The processing column is a list of what actions are to be performed to achieve the required
output.
Let us look first at a real world scenario. You are learning to bake a cake for the first time. How
would you represent this problem using the defining diagram concept? See the example below.
Defining Diagram:
INPUT PROCESSING OUTPUT
1. Get the ingredients
2. Combine the ingredients The Cake
The Ingredients such as 3. Preheat oven
eggs, butter, flour etc. 4. Place the combine
ingredients in
baking tin
5. Place baking tin in
the preheated oven
6. Leave cake to
bake at the desired temperature
Example 1
A program is required to read two (2) numbers calculate and print their total.
Steps in drawing the defining diagram using the example above.
1. Identify the input (that is, the data that is given). The keyword, read, identifies the input
as two numbers, that is, any two numbers.
2. Identify the output. The keyword, print, identifies the output as the total (or sum) of the
two numbers.
3. List the processing steps. Here, we list all the actions that must be performed in order
to get the desired results. For example: What do we have to do to the two numbers in
order to print their total?
1. We must first get the numbers.
2. We must then calculate their sum.
3. We must then print the total.
Defining Diagram:
INPUT PROCESSING OUTPUT
1. Read/get 2 numbers
2 Numbers 2. Add numbers together TOTAL
3. Print total
Example 2
Problem 2
A program is required to read three numbers calculate and print their product.
7
Defining Diagram
Activity 1
Activity 2
Write instructions to teach your friend how to turn on a computer and then to access his/her
email.
Possible solution