20.03.2013 Views

II. Notes on Data Structuring * - Cornell University

II. Notes on Data Structuring * - Cornell University

II. Notes on Data Structuring * - Cornell University

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

142 c.A.R. HOARE<br />

trap of supposing that this will help when there is a basic mismatch in the<br />

speeds of processing and transfer. In general, if double or triple buffering is<br />

inadequate, it is not worth while filling the store with any further extra<br />

buffers.<br />

In a machine which is endowed with an automatic paging scheme, the<br />

problems of representing sequences are very much reduced. As far as the<br />

programmer is c<strong>on</strong>cerned, he need <strong>on</strong>ly allocate the amount of storage<br />

required for the l<strong>on</strong>gest possible sequence, using the c<strong>on</strong>tiguous representa-<br />

ti<strong>on</strong>. This should not actually cause any waste of storage, since the paging<br />

system should delay allocati<strong>on</strong> of store until it is first used. As the sequence<br />

expands, new blocks of store will be allocated, but the addressing of these<br />

blocks will appear c<strong>on</strong>tiguous to the programmer, so there is no problem<br />

of leaving unused space at the end of blocks which are not large enough to<br />

hold the next item. Shortly after a block has been filled, it will automatically<br />

migrate to backing store; and it will be brought back again automatically<br />

as so<strong>on</strong> as it is required. On input sequences, a block which has been scanned<br />

will also be removed shortly afterwards from main store; but this will not<br />

involve an unnecessary backing store transfer if the material has not been<br />

changed since the last input took place. The <strong>on</strong>ly operati<strong>on</strong> which a paging<br />

system will not perform automatically is to read a block of an input sequence<br />

into store ahead of its actual requirement.<br />

9. RECURSiVE DATA STRUCTURES<br />

There are certain close analogies between the methods used for structuring<br />

data and the methods for structuring a program which processes that data.<br />

Thus, a Cartesian product corresp<strong>on</strong>ds to a compound statement, which<br />

assigns values to its comp<strong>on</strong>ents. Similarly, a discriminated uni<strong>on</strong> corresp<strong>on</strong>ds<br />

to a c<strong>on</strong>diti<strong>on</strong>al or case c<strong>on</strong>structi<strong>on</strong>, selecting an appropriate processing<br />

method for each alternative. Arrays and powersets corresp<strong>on</strong>d to for state-<br />

ments sequencing through their elements, with an essentially bounded<br />

number of iterati<strong>on</strong>s.<br />

The sequence structure is the first that permits c<strong>on</strong>structi<strong>on</strong> of types of<br />

infinite cardinality, with values of unbounded length; and it corresp<strong>on</strong>ds to<br />

the unbounded form of looping, with a while c<strong>on</strong>diti<strong>on</strong> to c<strong>on</strong>trol terminati<strong>on</strong>.<br />

The reas<strong>on</strong> why the sequence is unbounded is that <strong>on</strong>e of its comp<strong>on</strong>ents<br />

(i.e. the initial segment) from which it is built up bel<strong>on</strong>gs to the same type as<br />

itself, in the same way as the statement which remains to be obeyed after<br />

any iterati<strong>on</strong> of a while loop is the same statement as before.<br />

The questi<strong>on</strong> naturally arises whether the analogy can be extended to a<br />

data structure corresp<strong>on</strong>ding to recursive procedures. A value of such a<br />

type would be permitted to c<strong>on</strong>tain more than <strong>on</strong>e comp<strong>on</strong>ent that bel<strong>on</strong>gs

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!