Chatper 7 Problem Solving and Algorithms

Ace your homework & exams now with Quizwiz!

List the three phases of the computer problem-solving model.

1. Algorithm development phase 2. Implementation phase 3. Maintenance phase

List the four steps in Polya's How To Solve It List.

1. Understanding the problem 2. Devising a plan 3. Carrying out the plan 4. Looking Back

The first strategy to use when given a problem.

A. Ask Questions

There is an apparent contradiction in the problem statement.

A. Ask Questions

The practice of hiding the details of a module with the goal of controlling access to the details of the module

A. Information hiding

General Solution

Algorithm development phase

Differentiate between a concrete step and an abstract step.

An abstract step is one in which further development is needed. A concrete step is one in which all the steps are fully specified.

What is an algorithm?

An algorithm is a set of instructions for solving a problem in a finite amount of time using a finite amount of data.

Problem Statement

Analysis and specification phase

List the problem-solving strategies discussed in this chapter.

Ask questions Look for familiar things Divide and conquer

Apply the problem-solving strategies to the following situations. Solutions are not unique. a. Buying a toy for your four-year-old cousin.

Ask questions: What do four-year olds like? Is he or she into sports? What stores sell toys? Where is a particular store located? What toys does the cousin already have? Look for things that are familiar: I liked Lincoln Logs; would my cousin? I liked my red wagon; would my cousin? My cousin is like his (or her) mother; what did she play with as a child? Divide and conquer: Go to store. Go to toy aisle. Fine girl's (or boy's) toys. Choose one.

A model of a complex system that includes only the details essential to the viewer

B. Abstraction

Don't reinvent the wheel.

B. Look for familiar things

Is a solution to a previous problem appropriate for the current one?

B. Look for familiar things

The separation of the logical view of data from its implementation

C. Data abstraction

Strategy used in the Quicksort algorithm

C. Divide and conquer

Strategy used in the binary search algorithms

C. Divide and conquer

The separation of the logical view of an action from its implementation

D. Procedural abstraction

Describe the top-down design process.

Describe the top-down design process. The top-down design process is characterized by successive layers of refinement. The top-level tasks are listed. At each succeeding level, the tasks from the previous one are further developed.

The separation of the logical view of a control structure from its implementation

E. Control abstraction

Describe the four steps listed in Exercise 37 in your own words.

Each student's answer is unique.

A binary search can be applied to both a sorted and unsorted array.

False

A binary search is always faster than a linear search.

False

A record is a homogeneous structure; an array is a heterogeneous structure.

False

Event-controlled loops repeat a specific number of times.

False

Loops can be nested, but selection structures cannot.

False

Recursion is another name for iteration.

False

Selection structures can be nested, but loops cannot

False

The bubble sort algorithm involves finding the smallest item in the unsorted portion of the array and swapping it with the first unsorted item.

False

The square root algorithm used a count-controlled loop

False

Working Program

Implementation phase

How does the computer problem-solving model differ from Polya's?

In Polya's list, the human executes the plan and evaluates the results. In a computer solution, a program is written that expresses the plan in a language that the computer can execute. The human then takes the computer output and evaluates the results.

Why is information hiding important?

Information hiding defers details until the level where the details are important. This process keeps an algorithm from being dependent on the implementation details, which may change.

Distinguish between information and data.

Information is any knowledge that can be communicated. When information is in the form that a computer can use, it is called data. Thus data is any knowledge that can be communicated in a form that a computer can process.

None

Maintenance phase

Name three examples of information hiding that you encounter every day.

Talking on the telephone. Driving a car. Turning on the television.

Describe the steps in the algorithm development phase.

The algorithm development phase includes analysis (understanding the problem), proposed solution (logical sequence of solution steps), and testing (following algorithm).

Describe the steps in the implementation phase.

The implementation phase includes coding (translating the algorithm into a computer language) and testing (compiling and running the program).

Describe the steps in the maintenance phase.

The maintenance phase involves using the program and modifying the program to add functionality or correct errors.

A record is a heterogeneous structure, but an array is not

True

A selection sort puts one more item into its permanent place at each iteration.

True

All control structures can be nested

True

An array is a homogeneous structure, but a record is not

True

An infinite loop is a loop that never terminates.

True

An insertion sort puts one more item into its place with respect to the already sorted portion.

True

Count-controlled loops are controlled by a counter.

True

Count-controlled loops repeat a specific number of times.

True

Event-controlled loops are controlled by an event.

True

Iterative algorithms use WHILE statements.

True

Quicksort is not always quick.

True

Recursive algorithms use IF statements.

True

Write and algorithm for the following tasks. Solutions are not unique. c. Doing your homework

Turn off TV Turn off CD Get backpack Sit at desk Open backpack Pet cat Open book Open assignment


Related study sets

Official facts about Great Britain

View Set

Psychological Testing and Assessment

View Set

Sociology Ch. 5: Social Interaction, Groups, and Social Structure

View Set