12
CHAPTER
we choose to hold a collection of data objects play an
important role in the design process. In the last two chapters, we dis-
cussed the one-dimensional array and its use in problems where the log-
ical representation of the data is a list of objects. The choice of data
structure directly affects the design, because it determines the algo-
rithms used to process the data objects. For example, if the data items are
stored in sorted order within the array, we can apply a binary search al-
gorithm to them rather than a linear search.
In many problems, however, the relationships between data items are
more complex than can be represented in a simple list. For example, we
need a more sophisticated data structure when simulating board games
(such as chess, Tic-Tac-Toe, or Scrabble), computer graphics (where points
on the screen are arranged as a two-dimensional object), or matrix op-
erations in mathematics. In this chapter we examine the two-dimen-
sional array, which is useful when we need to organize data in two
dimensions. We usually call these dimensions rowsand columns.
In addition, we extend the definition of an array to allow arrays with
any number of dimensions, called multidimensional arrays. Each dimen-
sion represents a different feature of the data objects in the structure. For
example, we might use a three-dimensional array to store objects repre-
senting sales figures by (1) store number, (2) month, and (3) item number.
Finally, we take a closer look at the limitations of the computer in do-
ing calculations, noting how these limitations can cause numerical errors
and how we can avoid such errors. This discussion relates directly to the
Case Study, in which we examine arrays as implementation structures for
two mathematical objects, vector and matrix.
The structures that
1985
Microsoft releases
Windows 1.0. It is
their first in a series
of widely-used
operating systems
1985
Intel introduces the
80386, a 32-bit
processing chip with
on-chip memory
management
1985
Paul Brainard
creates PageMaker,
and launches the
world of PC desktop
publishing
1986
The Cray XMP
supercomputer
executes 713 million
floating-point
calculations per
second
1988
Microprocessor
speeds reach 17
million instructions
per second with
Motorola’s 88000
chip
1988
Robert Morris Jr.
releases a worm
program into the
Internet,
demonstrating the
need for greater
network security