ITM 207 Chapter 7
Steps To Solve Problems
1. Understand the problem 2. Devise a plan 3. Carry out the plan 4. Look back
Record
A collection of related fields that make up a single database entry A named heterogeneous collection of items in which each individual item is accessed by NAME e.g. name, age, hourly wage makes up a single entry for this
Array
A named homogeneous collection of items in which an individual item is accessed by it's position (index) As data is being read, a counter is updated so we know how many data items are being stored
Algorithm
A set of unambiguous instructions for solving a problem or a subproblem in a finite amount of time using a finite amount of data 2 Types of steps: Abstract, Concrete
Concrete Step
Algorithmic step where all the details ARE specified
Abstract Step
Algorithmic step where all the details AREN'T specified
Control Structure
An instruction that determines the order in which other instructions in a program are executed
Computer Problem Solving Phases
Analyze and Specification Phase (analyze/specify) Algorithm Development Phase (develop/test) Implementation Stage (code/test) Maintenance Phase (use/maintain)
Summary of Methedology
Analyze the problem List the main tasks List the remaining tasks Re-sequence and revise as necessary
Problem Solving Strategies
Ask questions - Never reinvent the wheel Divide and Conquer
Sequential Search Of An Unsorted Array
Examines each item and compares to each one being searched for If matched, item is found If not, search continues till item is found or entire list has been searched
Selection Sort
Find what data entry comes first Move it to the top Repeat sequence
Object-Oriented Design
Focuses on data involved in the situation
Top Down Design
Focuses on tasks to be completed
Paramter
Identifiers listed in parentheses beside the subprogram declaration also known as FORMAL __________
Argument
Identifiers listed in parentheses on the subprogram call sometimes refer to ACTUAL PARAMTERS
Binary Search
List must be sorted Search begins in the middle Searches one half at a time If found, other half is eliminated If not found, unexamined half is searched
Re-sequence And Revise As Necessary
Process ends when all steps are completed
Composite Data Types
Records, and Arrays
Write The Remaining Models
Restate each abstract model as a list of tasks, give each a task a name
List The Main Tasks (Become main modules)
Restate each problem as a list of tasks, give each task as a name
Bubble Sort
Start from the bottom Compare first 2 items Switch occurs so the higher value is above Starting with the last list pair, compare successive pairs of elements
Insertion Sort
Start from the top Compare first 2 items Keep the highest value on top
Problem Solving
The act of finding a solution to a perplexing, distressing, vetting, or unsettled question
Count-Controlled Loops
The count is kept in a variable (index/count) Number of repetitions is known before the program is executed
Event-Controlled Loops
The number of repetitions is controlled by an event that occurs within the body of the loop itself
Analyze The Problem
Understand the problem, devise a plan of attack
Sequential Search Of A Sorted Array
We can stop searching when we pass the place where the item can be