0% found this document useful (0 votes)
29 views

Programming - Steps in Problem Solving

The document outlines the objectives and steps of a lesson on problem solving and program design. The lesson will teach students to [1] outline the steps in problem solving which includes defining the problem, proposing and evaluating solutions, determining the best solution, and representing and testing the algorithm; [2] use a divide-and-conquer approach to decompose large problems into smaller subproblems; and [3] define problems using input-process-output diagrams and other tools. The document provides examples of applying these concepts to everyday problems.

Uploaded by

Kevin Edmondson
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Programming - Steps in Problem Solving

The document outlines the objectives and steps of a lesson on problem solving and program design. The lesson will teach students to [1] outline the steps in problem solving which includes defining the problem, proposing and evaluating solutions, determining the best solution, and representing and testing the algorithm; [2] use a divide-and-conquer approach to decompose large problems into smaller subproblems; and [3] define problems using input-process-output diagrams and other tools. The document provides examples of applying these concepts to everyday problems.

Uploaded by

Kevin Edmondson
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

PROBLEM SOLVING

AND PROGRAM
DESIGN

Instructor: Ms. Brown


General Objectives of the Lesson

 At the end of the lesson, students should be able to:


 Outline the steps in problem solving
 Use a divide-and-conquer approach to decompose large
everyday problems into smaller tasks.
 Define a problem by decomposing it into significant
components.
 Distinguish between variables and constants
 Explain the concept of algorithm
 Represent algorithms in the form of pseudocode and
flowcharts.
 Test algorithms for correctness.
Betty Williams had
quoted, “There’s no use
talking about the problem
unless you talk about the
solution”.
Specific Objectives of the
lesson

Objective1.1: Outline the steps in problem


solving
Objective1.2: Use a divide-and-conquer
approach to decompose large everyday problems
into smaller tasks.
Objective1.3: Define a problem by decomposing
it into significant components.
Key terms in Problem Solving

 Problem-solving is the process of


creating a set of instructions that, when
executed, accepts input data and
produces meaning information.

 Solution- A solution is a set of


instruction that, if followed in order, will
produce the required information.
Steps in Problem Solving

Define the
problem

Test and Propose and


validate the evaluate
solution solutions

Represent
the solution Determine
as the best
pseudocode solution
or flowchart
Step 1:Define the Problem

 Aim is to understand the problem. Start


with a clear description of the problem in
narrative form. An Input-Process-Output
(I-P-O) chart is used to break the problem
down into three main component parts.
Example Problem 1
 We have to get to school on time. Our school is located 5
kilometers from our home. Our parents have given us a $500
allowances for transportation and for other spending.
I have a
$500 Should I
allowance ride my
… bicycle???

Should I
take Should I
the walk to
taxi??? school???

Should I
take the
bus???
Step 2:Propose and evaluate solutions

 Consider alternative solutions to the problem. Evaluate


each proposed solution.
 Example Problem 1
 We need to get to school on time using a reliable mode
of transportation, while trying to save some money.
 There are a number of tools we can use, one of which is
the idea web tool, where we can list our different
options.
Idea web for the problem of how to get to school

Most
costly
Fastest
(10 Reliable
mins)

Taxi
Cost $100
Takes
(save
fairly $400)
long (25
mins) Problem Statement
We need to get to
school on time 15
Costs
least and
Bicycle using a reliable
mode of Bus mins
transportation
save all while trying to save
the some money.
money

Reliable
Fairly
but can reliable
be tiring

Walk
Takes
longest
Reliable
(45
but most
mins) Costs tiring
least and
saves all
the
money
Step 3: Determine the best solution

 Based on the evaluation of the solutions from the


previous step, determine which one is best.
 Example Problem 1
 We need to get to school on time using a reliable mode
of transportation, while trying to save some money.
 WE can use the “Five W’s and How” question chart tool.

What do we want to do? Get to school on time


Where do we want to go? To school

When do we want to get there? Ten minutes before the first bell.

How do we want to arrive at school? Using fairly reliable transport

How much do we want to save? At least $100

How do we want to arrive at school? Not tired


Step 4:Represent the algorithm as
pseudocode or a flowchart

 Represent the solution as formal pseudocode or as a


flowchart.
Step 5:Test and validate the solution

 Test the pseudocode/flowchart for correctness using a


trace table. If the algorithm produces correct results for
a set of carefully selected test data then the design is
deemed valid and program implementation may begin.
Using the divide-and-conquer approach to
decompose large everyday problems into
smaller tasks
 Thedivide-and-conquer approach is to
repeatedly split a large problem into a
number of smaller sub-problems until a
complete solution is identified.
 Youuse the divide-and-conquer
approach in your everyday life.
Using the divide-and-conquer approach
to decompose large everyday problems
into smaller tasks
 Examples of divide-and –conquer
approach
 To fry an egg
1. Put your frying pan on a medium-
to-low heat
2. Add sufficient cooking oil to coat
the bottom of the pan.
3. Crack the egg into the pan
4. When the egg is cooked to your
liking, remove the pan from the
heat.
5. Transfer the egg onto a plate using
a spatula.
6. Enjoy your fried egg.
Using the divide-and-conquer
approach to decompose large
everyday problems into smaller tasks
 Examples of divide-and –
conquer approach
 Building a bicycle
1. Get a frame
2. Build the wheels and tyres
3. Make the brakes and cables
4. Make the chain and cogs
5. Get the handlebars
6. Assemble the complete
bicycle.
Defining the Problem

 Defining the problem is a way to help the


programmer understands what he or she is
required to do. It involves breaking down the
problem into three (3) key components:
1. What is given (the input)
2. The expected results (the output)
3. The tasks that must be performed (processing)
These three (3) components can be illustrated
using what is called a defining diagram. Some
texts 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(3) columns, which
represent the three(3) components: Input,
processing and output.

Input Processing Output


 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 OR OUTPUT.
The Processing
The processing column is a list of what actions are to be
performed to achieve the required output.
Defining Diagram In class
examples

1. A program is required to read three


numbers, calculate and print their product.
Input Processing Output

Three numbers Read three Product


numbers

Calculate the
product by
multiplying the
three numbers.

Print the product


of the three
numbers.
2. Write a program to enter the length and width of a rectangle
and find and print the area.

Input Processing Output


Length, Width Read the length Area
and width of a
rectangle

Calculate area
Area= Length *
Width

Print the area of


a rectangle
3. Write a program to read the mass of an item in pounds
and convert it to kilograms. Kg = lb * 2.2, where kg is
kilograms and lb is pounds. Output the weight in pounds
and kilograms.

Input Processing Output


Pounds -lb Read the mass of Pounds,
an item in kilograms
pounds.

Convert pounds
to kilograms
Kg = lb * 2.2

Print the weight


in pounds and
kilograms.

You might also like