Você está na página 1de 16

Problem Solving

What is a problem?
A problem is something that needs to be solved.
What is a Solution?
A solution is the answer to a problem
Problem Solving
Problem solving is the process of finding solution to a problem
Steps to Solving a Problem
1) Define a problem (Know what is wrong)
2) Propose and evaluate solutions (try to come up with different ways
to resolve issue)
3) Determine the most efficient solution (Choose the BEST solution)
4) Write or draw an algorithm
5) Test the solution
What is an algorithm?
This is a formal sequence of instructions to solve a problem.
An algorithm is like a recipe. The recipe tells you the ingredients that
are needed to cook a meal and the steps to prepare the meal.
In Computer Science the algorithm outlines steps for solving a
problem.
Characteristics of an algorithm
It should produce the correct answer
It should be unambiguous
It should be logical
It should precise
Lets Solve the problem
Scenario: You walk in a room and noticed your little brother crying.
Do you think there is a problem?
If there is a problem how will you know what it is?

This is called Defining the problem.


Before you can solve a problem you must know what it is.
Scenario: Your brother responded by saying he was stressed out
because his friend is not talking to him anymore.
Identify THREE ways you think your brother can resolve the issue he is
having.

This is called Proposing and Evaluating Solution


Solving Computer Related
Problems
Define the problem:
A) identify the problem.what is it that needs to be fixed.

For Example: Write an algorithm that accepts two numbers and finds and prints the sum of
the two numbers.

Problem: The problem is to find and print the sum of two unknown number

B) Break up the problem into its components. The are four components to a
problem (Input, Output, Processing, and Storage)
Components of a problem
Input: This is the data (ingredients) that you will need to put in a
computer in order to solve a problem.
Keywords to identify input: They usually follow words such as
accepts, enters, input, put in etc.
In the example on Slide 10 (Write an algorithm that accepts two
numbers and find and print the sum of the two numbers).
Question: What would be the input?
The input would be two numbers.
Contd Components of a
problem
Processing : This is all the steps the computer needs to carry out in
order to generate a solution.
In the example on Slide 10 (Write an algorithm that accepts two
numbers and finds and prints the sum of the two numbers).
The process would be:
1) prompt the user
2) Accept the two numbers
3) Add the two numbers
4) Print the sum
Contd Components of a
problem
Output: This is what needs to be printed or displayed.
Keywords to identify output includes generates, produces, outputs,
prints or shows.
In the example on Slide 10 (Write an algorithm that accepts two
numbers and finds and prints the sum of the two numbers).
The output is the Sum of the two unknown numbers.
Contd Components of a
problem
Storage: These are the containers that will hold the values in the
algorithm.
Just as in Baking you have to add sugar, butter , water and egg in a
container, input and output have to be placed in containers.
The two containers in algorithms are :
1) variables: is a container that holds a value that may change throughout the
execution of a program
2) Constants: is container that holds a value that will remain fix (unchanged)
throughout the execution of a program.
Lets define the following
problem
Identify the problem in the following problem statements. In addition
identify the input, processes and storage.

1. Write an algorithm that accepts two numbers. Your algorithm should


divide the first number by the second number. Print the answer.
2. Write an algorithm that accepts four numbers. Find and print the
sum.
3. Write an algorithm that accepts the length of the side of a square.
Find and print the perimeter of the square.
4) Write an algorithm that accepts three number numbers. Find and
print the average.

Você também pode gostar