You are on page 1of 71

Processing Arrays

Chapter 9

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Objectives
1. Develop problem solutions for the computer using one-dimensional and two dimensional arrays. 2. Develop problem solutions requiring table look-ups, sequential and binary searches, frequency distributions, and crosstabulations.

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.1 Base-Zero Versus Base-One Arrays

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.2 One-Dimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.3 Parallel Arrays

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.4a Loading an Array Using the Automatic-Counter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.4b Loading an Array Using the Repeat/Until Loop

* The number of elements in the array should not include the trip value of -1.

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.4c Loading an Array Using the While/WhileEnd Loop

* The number of elements in the array should not include the trip value of -1.

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.5 Printing a OneDimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.6 Accumulating the Elements of a OneDimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7a Problem Analysis Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7b Interactivity Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7b IPO Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7c Coupling Diagram

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7c Data Dictionary

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7d Algorithms and Flowcharts for Control Module

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7d Algorithms and Flowcharts for Init Module

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7e Algorithm and Flowchart for the Read Module

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7f Algorithm and Flowchart for the Calc Module

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.7g Algorithm and Flowchart for the Print Module

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.8 General Form of a Two-Dimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.9 Loading a TwoDimensional Array, Row by Row and Column by Column

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.10 Printing a Two-Dimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.11 Accumulating a Two-Dimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.12 Algorithm for Column and Row Summation

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.12 Flowchart for Column and Row Summation

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13a Problem Analysis Chart for Array Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13b Interactivity Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13c IPO Chart for Array Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13d Coupling Diagram

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13d Data Dictionary

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13e Algorithm and Flowchart for Control Module

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13f Algorithm and Flowchart for Init Module for Array Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13g Algorithm and Flowchart for Read Module for Array Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13h Algorithm and Flowchart for Calc Module for Array Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.13i Algorithm and Flowchart for Print Module for Array Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.14 Three-Dimensional Array

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.15 Table Look-Up Technique

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.16 Search Algorithm and Flowchart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.17a The Binary Search

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.17b Example of a Binary Search

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.18a Algorithm and Flowchart of Control Module for a Frequency Distribution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.18b Algorithm and Flowchart of Init Module for a Frequency Distribution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.18b Algorithm and Flowchart of Read Module for a Frequency Distribution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.18c Algorithm and Flowchart of Calc Module for a Frequency Distribution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.18c Algorithm and Flowchart of Print Module for a Frequency Distribution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.18d Example of a Frequency Distribution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19a Algorithm of Control Module for Cross-Tabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19a Flowchart of Control Module for Cross-Tabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19b Algorithm and Flowchart of Init Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19c Algorithm of Enter Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19c Flowchart of Enter Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19d Algorithm of ChooseOptions Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19d Flowchart of ChooseOptions Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19e Algorithm of Calc Module for Cross-Tabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19e Flowchart of Calc Module for Cross-Tabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19f Algorithm of Print Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.19f Flowchart of Print Module for CrossTabulation Solution

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20a Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20b Problem Analysis Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20c Interactivity Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20c IPO Chart

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20d Algorithm of Absent Control Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20d Flowchart of Absent Control Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20e Algorithm and Flowchart of Init Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20f Algorithm and Flowchart of Menu Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20f Flowchart of Menu Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20g Algorithm and Flowchart of Enter Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20h Algorithm of Calc Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20h Flowchart of Calc Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 9.20i Algorithm and Flowchart of Print Module for PIAT Cross-Tabulation Problem

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

You might also like