Class2 Notes
Class2 Notes
2
Concept Lesson
• Problem Solving
• Solving Everyday Problems
• Creating Computer Solutions to Problems
• Analyzing the Problem
• Planning the Algorithm
• Desk-Checking the Algorithm
• The Gas Mileage Problem
• Summary
3
Problem Solving
4
Solving Everyday Problems
5
Solving Everyday Problems
(continued)
6
Solving Everyday Problems
(continued)
7
Creating Computer Solutions to
Problems
• Analysis tools: IPO charts, pseudocode, flowcharts
• To desk-check or hand-trace, use pencil, paper,
and sample data to walk through algorithm
• A coded algorithm is called a program
8
Creating Computer Solutions to
Problems (continued)
9
Analyzing the Problem
10
Analyzing the Problem (continued)
11
IPO Charts
12
IPO Charts (continued)
14
Analyzing the Problem (continued)
15
Analyzing the Problem (continued)
16
Analyzing the Problem (continued)
17
Planning the Algorithm
18
Planning the Algorithm (continued)
19
Planning the Algorithm (continued)
20
Planning the Algorithm (continued)
21
Planning the Algorithm (continued)
22
Hints for Writing Algorithms
23
Hints for Writing Algorithms
(continued)
You may use a portion of a previous solution to solve current problem
24
Desk-Checking the Algorithm
25
Desk-Checking the Algorithm
(continued)
26
Desk-Checking the Algorithm
(continued)
• Valid data is data that the programmer is
expecting the user to enter
• Invalid data is data that he or she is not expecting
the user to enter
• You should test an algorithm with invalid data
– Users may make mistakes when entering data
27
Summary
• Problem-solving typically involves analyzing the
problem, and then planning, reviewing, implementing,
evaluating, and modifying (if necessary) the solution
• Programmers use tools (IPO charts, pseudocode,
flowcharts) to help them analyze problems and
develop algorithms
– During analysis, you determine the output and input
– During planning, you write the steps that will transform
the input into the output
28
Summary (continued)
• After the analysis and planning, you desk-check
the algorithm
– Follow each of the steps in algorithm by hand
• Coding refers to translating the algorithm into a
language that the computer can understand
• Before writing an algorithm, consider whether you
have already solved a similar problem
29