Intro Problemsolving
Intro Problemsolving
Outline
• General Problem-Solving Concepts:
– Types of Problems
• Problem Solving with Sequential Structure
• Discussion & Practice of Pseudocodes
• Generating Flowcharts.
2
Types of Problem
• The simple problem
– simple and obvious.
– already been solved
• The complicated problem
– don’t know the answer, but they know how to find it.
– a known unknown
• The complex problem
– take some sort of action to see what happens before you
act again.
– answers aren’t known
Types of Problems
Problems do not always have straightforward solutions
• Algorithmic solutions
Problems that can be solved with a series of actions
Ex: Baking a cake
The solution will be the same each time the
algorithm is followed
The solution of a problem can be reached by
completing the actions in steps. These steps are
called the algorithm.
Types of Problems –
Cont.
• Heuristic solutions
Solutions that cannot be reached through a direct set
of steps
Example: expanding a company
These solutions require reasoning built on knowledge
and experience, and a process of trial and error
The results may not produce the same results each
time the algorithm is executed
Problem Solving with Computers
Computers
which
humansare are built
often to deal
difficult or with
very algorithmic
time solutions,
consuming for
• The field of
problems computers
is called thatintelligence.
artificial deals with heuristic types of
• Artificial
build its
language.
intelligence
own enables
knowledge bank aand
computer
speak toado
in things like
human
Programming: Plan First, Then Code
• A good programmer will plan first and write
second
– Breaking down a large programming task into
several smaller tasks
An Overview of Seven Steps
Algorithm
• Set of well-defined logical steps that must be
taken to perform a task
• For example, suppose you have been asked to write a
program to calculate and display the gross pay for an
hourly paid employee.
Here are the steps that you would take:
1. Get the number of hours worked.
2. Get the hourly pay rate.
3. Multiply the number of hours worked by the hourly pay rate.
4. Display the result of the calculation that was performed in Step 3.
Pseudocode
• Pseudocode: fake code
– Informal language that has no syntax rule
– Not meant to be compiled or executed
– Used to create model program
• No need to worry about syntax errors, can focus on program’s
design
• Can be translated directly into actual code in any programming
language
Flowcharts
• Flowchart: diagram that graphically depicts
the steps in a program
– Ovals are terminal symbols
– Parallelograms are input and output symbols
– Rectangles are processing symbols
– Symbols are connected by arrows that represent
the flow of the program
Start
Flow Chart
End
First Four Steps