Chapter 7 ITM 207 Final Exam Notes
Problem Solving and Algorithms
The act of finding a solution to a perplexing, distressing, vexing, or unsettled
How to Solve It: A new Aspect of Mathematical Method by George Polya
“How to solve it list” written within the context of mathematical
How do you solve problems?
- Understand the problem
- Devise a plan
- Carry out the plan
- Look back
- Ask Questions
o What do I know about the problem?
o What is the information I have to process in order to find the solution?
o What does the solution look like?
- Similar problems come up again and again
- A good programmer recognizes problems that have been solved before and
uses past solutions
- Divide and Conquer
o Break up a large problem into smaller units and solve each smaller
Applies the concept of abstraction
The divide-and-conquer approach can be applied over and
over again until subtask is manageable
Computer Enabled Problem Solving:
- Analysis and Specification Phase
- Algorithm Development Phase
o Develop Algorithm
o Test Algorithm
- Implementation Phase
o Code algorithm
o Test Algorithm Chapter 7 ITM 207 Final Exam Notes
- Maintenance Phase
arrow can be
added if the
A set of unambiguous instructions for solving a problem or sub-problem in a
finite amount of time using a finite amount of data.
An algorithmic step containing unspecified details.
An algorithmic step in which all details are specified.
Developing an Algorithm:
Two methods to develop computer solutions to a problem:
o Top-down design focuses on the tasks to be done
o Object-oriented design focuses on the data involved in the solution.
Summary of Methodology:
- Analyze the problem
o Understand the problem Chapter 7 ITM 207 Final Exam Notes
o Develop a plan of attack
- List the Main Tasks (becomes main module)
o Restate problem as a list of tasks (modules)
o Give each task a name
- Write the remaining Modules
o Restate each abstract module as a list of tasks
o Give each task a name
- Re-sequence and revise as necessary
o Process ends when all steps (modules) are concrete
for as many levels
as it takes to
make every step
Name of the (sub)
problem at one
level becomes a
module at next
An instruction that determines the order in which other instructions in a
program are executed.
statement Chapter 7 ITM 207 Final Exam Notes
Algorithm with Selection:
Problem: Write the appropriate dress for a given temperature.
Write "Enter temperature" IF (temperature > 90)
Read temperature Write “Texas weather: wear shorts”
ELSE IF (temperature > 70)
Write “Ideal weather: short sleeves are fine”
ELSE IF (temperature > 50)
Write “A little chilly: wear a light jacket”
^^ Abstract ^^ ELSE IF (temperature > 32)
>> Concrete >> Write “Philadelphia weather: wear a heavy coat”
Write “Stay inside”
Flow of control of
A count-controlled loop: An event-controlled loop:
Set sum to 0 Set sum to 0
Set count to 1 Set allPositive to true
While (count <= limit) WHILE (allPositive)
Read number Read number
Set sum to sum + number IF (number > 0)
Increment count Set sum to sum + number
Write "Sum is " + sum ELSE
Set allPositive to false
Write "Sum is " + sum Chapter 7 ITM 207 Final Exam Notes
Composite Data Types:
A named heterogeneous collection of items in which individual items are
accessed by name. For example, we could bundle name, age and hourly wage
items into a record named Employee.
A named homogeneous collection of items in which an individual item is
accessed by its positio