# ITM207 Exam Notes- Ch 7.docx

Unlock Document

Ryerson University

Information Technology Management

ITM 207

Jim Tam

Winter

Description

Problem solving
The act of finding a solution to a perplexing, distressing, vexing, or unsettled question
How do you solve a problem
Understand the problem
Devise a plan
Carry out the plan
Look Back
Strategies
*Ask Questions but *Never reinvent the wheel!
What do I know about the problem?
What is the information that I have to process in order the find the solution?
What does the solution look like?
What sort of special cases exist?
How will I recognize that I have found the solution?
*Ask Questions but *Never reinvent the wheel!
- Similar problems come up again and again
- A good programmer recognizes a task/subtask that has been solved before and plugs in solution
*Divide and Conquer
- Break up a large problem into smaller units and solve each smaller problem
- Applies the concept of Abstraction
- Approach can be applied over and over until each subtask is manageable
Computer Problem Solving
Summary of Methodology
Analyze the Problem
Understand the problem!!
Develop a plan of attack
List the Main Tasks (becomes Main Module)
Restate problem as a list of tasks (modules)
Give each task a name
Write the Remaining Modules
Restate each abstract module as a list of tasks
Give each task a name
Re-sequence and Revise as Necessary Process ends when all steps (modules) are concrete
Algorithms
A set of unambiguous instructions for solving a problem or subproblem in a finite amount of time using a
finite amount of data
Algorithms with Selection
E.x.
1. Write “Enter Temperature”
2. Read Temperature
3. Determine what to wear.
IF (temperature > 90)
Write “Texas weather: wear shorts”
ELSE IF (temperature > 70)
Write “Ideal weather: short sleeves are fine”
ELSE
Write “Stay inside”
Abstract Step
An algorithm step with unspecified details
Concrete Step
An algorithm step with all details specified
Developing Algorithms (to solve a computer problem)
Top-Down Design- Focuses on tasks to be done
Object-Oriented Design- Focuses on that data involved in the solution
Control Structure- An instruction that determines the order of execution of instructions in a program
Looping Statements Count-Controlled Loop- A count-controlled loop is a condition-controlled loop with predictable number of
iterations. The loop starts at some number (usually the topmost number or zero), then counts down until it reaches
the limit (usually zero or the topmost number), at which point it exits the loop. The other common type starts at zero
or one, and increments until it reaches a destination number.
Set sum to 0
Set count to 1
While (count <= limit)
Read number
Set sum to sum + number
Increment count
Write "Sum is " + sum
Event-Controlled Loop- In computer science, the event loop, message dispatcher, message loop, message pump, or
run loop is a programming construct that waits for and dispatches events or messages in a program. It works by
making a request to some internal or external "event provider" (which generally blocks the request until an event has
arrived), and then it calls the relevant event handler ("dispatches the event").
Set sum to 0
Set allPositive to true
WHILE (allPositive)
Read number
IF (number > 0)
Set sum to sum + number
ELSE
Set allPositive to false
Write "Sum is " + sum
Calculating Square Root
Read in square
Calculate the square root
Write out square and the square root
Set epsilon to 1
WHILE (epsilon > 0.001)
Calculate new guess
Set epsilon to abs(square - guess * guess)
Calculate Guess
Set newGuess to
(guess + (square/guess)) / 2.0
End
Read in square
Set guess to square/4
Set epsilon to 1
WHILE (epsilon > 0.001)
Calculate new guess
Set

More
Less
Related notes for ITM 207