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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

NOTES ON DATA STRUCTURING 121<br />

The choice between representati<strong>on</strong>s of multidimensi<strong>on</strong>al arrays is made<br />

<strong>on</strong> quite different grounds. The standard representati<strong>on</strong> is more ec<strong>on</strong>omical<br />

of storage, and gives good efficiency <strong>on</strong> sequencing through elements of the<br />

array by rows, columns, or both. Furthermore, it is more c<strong>on</strong>venient when<br />

the arrays must be transferred as a whole between main and backing store.<br />

However, <strong>on</strong> a machine with slow multiplicati<strong>on</strong>, it will be faster to use the<br />

tree representati<strong>on</strong>, and accept the extra storage required to hold the array<br />

of addresses, which is small provided that the rows are not too short. If<br />

each row c<strong>on</strong>tains <strong>on</strong>ly two words, there would be a fifty per cent overhead<br />

<strong>on</strong> data storage.<br />

There are several other possible reas<strong>on</strong>s for choosing the tree represen-<br />

tati<strong>on</strong>:<br />

(1) In some computing envir<strong>on</strong>ments, where dynamic storage allocati<strong>on</strong><br />

is standard, it may be difficult to obtain large c<strong>on</strong>secutive areas, in which<br />

case a large two-dimensi<strong>on</strong>al array can be split up into a number of smaller<br />

rows which can be accommodated without trouble.<br />

(2) It is possible to set up a scheme whereby some rows of the array are<br />

held <strong>on</strong> backing store while other rows are being processed, and then the<br />

backing store address of a row replaces the main store address in the base<br />

array when that row is absent from store. Thus it is hoped to be able to process<br />

arrays which are too large to be wholly accommodated in main store together<br />

with the program that processes them. However, the ec<strong>on</strong>omics of this<br />

operati<strong>on</strong> need to be carefully examined to ensure that the number of<br />

backing store transfers involved is acceptable.<br />

(3) In some applicati<strong>on</strong>s, it is known that several matrices share the same<br />

rows. In the tree representati<strong>on</strong> it is possible to set up a single copy of such a<br />

shared row, and merely take copies of its address rather than its full value.<br />

But in such a case, the shared row must not be selectively updated.<br />

(4) The tree representati<strong>on</strong> is recommended even in the case of single-<br />

dimensi<strong>on</strong>al arrays if the size of the individual elements is highly variable;<br />

and <strong>on</strong> multidimensi<strong>on</strong>al arrays, if the length of the rows is highly variable.<br />

Exercise<br />

The character set of an input device includes <strong>on</strong>ly thirty characters, defined<br />

by enumerati<strong>on</strong>; they include the characters space, newline, newpage.<br />

Characters may be read in <strong>on</strong>e at a time from an input device to a buffer,<br />

using a procedure call<br />

read next character.<br />

They should be assembled line by line into an array<br />

page'display page,

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

Saved successfully!

Ooh no, something went wrong!