II. Notes on Data Structuring * - Cornell University
II. Notes on Data Structuring * - Cornell University
II. Notes on Data Structuring * - Cornell University
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
NOTES ON DATA STRUCTURING 95<br />
In the case of a large data structure, the standard method of operating<br />
efficiently <strong>on</strong> it is not by assigning a wholly new value to it, but rather by<br />
selectively updating some relatively small part of it. The usual notati<strong>on</strong> for<br />
this is to write <strong>on</strong> the left of an assignment an expressi<strong>on</strong> (variable) which<br />
uses selectors to denote the place where the structure is to be changed.<br />
However, we also introduce special assignment operators, always beginning<br />
with col<strong>on</strong>, to denote other more general updating operati<strong>on</strong>s such as adding<br />
a member to a set, or appending an item to a sequence. For both kinds of<br />
selective updating, it must be remembered that, from a c<strong>on</strong>ceptual or abstract<br />
point of view, the entire value of the variable has been changed by updating<br />
the least part of it.<br />
2.3. REPRESENTATIONS<br />
It is fundamental to the design of a program to decide how far to store<br />
computed results as data for subsequent use, and how far to compute them<br />
as required. It is equally fundamental to decide how stored data should be<br />
represented in the computer. In many simple and relatively small cases there<br />
is an obvious standard way of representing data, which ensures that not too<br />
much storage is used, and not too much time expended <strong>on</strong> carrying out the<br />
basic operati<strong>on</strong>s. But if the volume of data (or the amount of processing)<br />
is large, it is often profitable (and sometimes necessary) to choose some<br />
n<strong>on</strong>-standard representati<strong>on</strong>, selected in accordance with the characteristics<br />
of the storage media used (drums, discs, or tapes), and also taking into<br />
account the relative frequencies of the various operati<strong>on</strong>s which will be<br />
performed up<strong>on</strong> it. Decisi<strong>on</strong>s <strong>on</strong> the details of representati<strong>on</strong> must usually<br />
precede and influence the design of the code to manipulate the data, often<br />
at a time when the nature of the data and the processing required are relatively<br />
unknown. Thus it is quite comm<strong>on</strong> to make serious errors of judgement in<br />
the design of data representati<strong>on</strong>, which do not come to light until shortly<br />
before, or even after, the program has been put into operati<strong>on</strong>. By this time<br />
the error is extremely difficult to rectify. However, the use of abstracti<strong>on</strong><br />
in data structuring may help to postp<strong>on</strong>e some of the decisi<strong>on</strong>s <strong>on</strong> data<br />
representati<strong>on</strong> until more is known about the behaviour of the program and<br />
the characteristics of the data, and thus make such errors less frequent and<br />
easier to rectify.<br />
An important decisi<strong>on</strong> to be taken is <strong>on</strong> the degree and manner in which<br />
data should be compressed in storage to save space; and also to save time <strong>on</strong><br />
input/output, <strong>on</strong> copying operati<strong>on</strong>s, and <strong>on</strong> comparis<strong>on</strong>s, usually at the<br />
expense of increasing the time and amount of code required to perform all<br />
other operati<strong>on</strong>s. Representati<strong>on</strong>s requiring less storage than the standard<br />
are usually known as packed; there are several degrees of packing, from