You are on page 1of 21

Introduction

Solving the Traffic Problem - Alfred Frueh


What is a Problem?

“The difference between


the current level of
performance of a task and
an attainable goal of
performing the task
better…”

~Skeete & Skeete


The Steps of Problem Solving

Propose and
Problem
Problem Analysis Evaluate Possible
Definition
Solutions

Implement the Develop the Most


Test and Validate
Algorithm (Write Appropriate
the Algorithm
the Program) Algorithm

Document and
Test and Debug
Maintain the
the Program
Program
One has to look carefully
and identify exactly what
the problem is and write
it down.

Definition of
the This is called the
Problem PROBLEM STATEMENT.

Example: Accept two


numbers (values).
Calculate and display the
sum of the two numbers.
Analyze the Problem

This step helps you to


take a complexed
problem and break it into It is the most important
smaller or easily step in problem solving
manageable
components.
Analyze the problem
In this step you would :
Identify the
Identify the inputs processing required
to be used or to achieve correct
required (INPUT) output
(PROCESSING)

Identify values to be
Identify required
stored if any
outputs (OUTPUT)
(STORAGE)
IPO Chart

Input Processing Output

A,B Sum = A+ B sum


Propose and Evaluate Possible
Solutions

This step involves examining all the possible


solutions to the problem and then select the best
one, given the resources available (e.g. time)
Develop an Algorithm

An algorithm is a finite
There are many different
number of accurate,
methods used for writing
unambiguous steps that
algorithms.
solve a problem

Examples of algorithms are:


narrative, flowcharts,
(We will focus on Narrative,
pseudocode, design
Flowchart and
structures, top down design
Pseudocode. )
approach, bottom up design
approach, etc.
Narrative Algorithm

• A narrative is a representation of an algorithm where each

instruction is written in everyday language


• Problem Statement: Accept 2 numbers. Calculate and display

their sum.

01 02 03 04 05 06
Step1: Start Step2: Get Step3: Add Step4: Store Step5: Display Step6: Stop
the two the numbers the results in sum
numbers Sum
FLOW CHART

 Terminator –indicates start or stop


 Process – indicates processing
 Input/output –indicates the input or output of
the problem
 Decision –used to make a decision between two
options i.e. yes or no
 Flow control – shows the flow of data
 Connector – used to connect part of a flowchart
that cannot fit on the page
Pseudocode algorithm uses words
and symbols that closely resemble
computer programming language
instructions

Example Problem Statement:


Accept two numbers (values) into
variables a and b. Add the two
values.
Pseudocode
Algorithm
Begin
Read a, b
sum  a + b
End
Characteristics of a Good Algorithm

The number
of steps
must be Steps must be Must
finite unambiguous terminate

Must be Must
precise have Must
flow lead to
control an
output
Steps for Developing an Algorithm

The input step

The processing step


• Assignment
• Decision
• Iteration (Loop)
• Arrays
The output step
Testing Algorithm

A trace table is a table that


tests an algorithm for
One good way of testing an
logical errors by calculating
algorithm is the use of a
each of the variables in
trace table
your algorithm one
statement at a time.
• Gay, G. & Blades, R. (2009),
Information Technology for CSEC.
Oxford University Press

References • Skeete, K. & Skeete, K. (2007).


Information Technology for CSEC.
Cambridge
Questions
• Watch the following videos and
make notes:
• (Input and output statements)
https://www.youtube.com/watch?v=
E5wr3kQbCyM

• (Variables and constants)


Homework https://www.youtube.com/watch?v=
o6z17TkruLw

• READ the handout/worksheet (Intro


to problem solving) from the
Moodle site.
The End
Thank you for
paying
attention!!!!!

You might also like