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 165<br />

An alternative and much simpler representati<strong>on</strong> is simply to record for<br />

each exam which sessi<strong>on</strong> it occurs in. This requires <strong>on</strong>ly<br />

array exam of 1.. 60<br />

This representati<strong>on</strong> is made possible <strong>on</strong>ly by the fact that the sessi<strong>on</strong>s of the<br />

timetable are mutually exclusive.<br />

(4) examcount : array exam of integer<br />

A standard representati<strong>on</strong> is the obvious choice.<br />

(5) remaining, untried, save 1, save 2<br />

These variables start rather full, and get emptier as the program progresses.<br />

Their average density is therefore about fifty percent, and there is no point<br />

in adopting a sparse representati<strong>on</strong>. Furthermore, the frequency of standard<br />

set operati<strong>on</strong>s applied to them indicate a standard bitpattern representati<strong>on</strong>.<br />

(6) incompat<br />

The most frequent use of elements of incompat is to subtract them from<br />

untried. They should therefore also use the bitpattern representati<strong>on</strong>. This<br />

will require 500 x 500 bits, of the order of 10000 words. This is by far the<br />

largest data structure required, but its total size is probably fully justified<br />

by the extra speed which it imparts to the program, and since it is acceptable<br />

<strong>on</strong> most computers <strong>on</strong> which this program will run, it does not seem worth<br />

while to seek a more compact representati<strong>on</strong>.<br />

(7) load<br />

The load of each student is the primary input data for the problem; it may<br />

also be extremely voluminous. It is therefore doubly fortunate that the<br />

program <strong>on</strong>ly needs to make a single scan of the data; for not <strong>on</strong>ly will this<br />

enable the data to be presented as an external sequence; it also means that<br />

the representati<strong>on</strong> can be designed to be suitable for human reading, writing,<br />

and punching.<br />

We therefore allocate <strong>on</strong>e card for each student, and use ten columns of<br />

six characters each to hold the examinati<strong>on</strong> numbers. To save unnecessary<br />

punching, the first blank column will signify the end of the examinati<strong>on</strong> set.<br />

For identificati<strong>on</strong> purposes, each card should also c<strong>on</strong>tain the student<br />

number; fortunately this can be wholly ignored by the program, though it<br />

should probably be checked to avoid duplicati<strong>on</strong>s or omissi<strong>on</strong>s.<br />

Exercise<br />

Code the abstract program described above using the recommended data<br />

representati<strong>on</strong>s.

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

Saved successfully!

Ooh no, something went wrong!