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

The problem now remains of selecting a suitable sessi<strong>on</strong> at each stage.<br />

In principle, there is no reas<strong>on</strong> to suppose that the "best" choice at each<br />

stage will lead to a "best" or even a "good" timetable in the end. However,<br />

it would seem that in general it will pay to select a combinati<strong>on</strong> of remaining<br />

exams that most nearly fills the hall, or most nearly approaches the limit k.<br />

This will probably mean that the majority of students and exams will be<br />

catered for in a reas<strong>on</strong>ably compact set of sessi<strong>on</strong>s, even though there may<br />

in the end be a fairly l<strong>on</strong>g "tail" of small sessi<strong>on</strong>s, involving a minority of<br />

students. Although this will not minimise the number of sessi<strong>on</strong>s, it may be<br />

reas<strong>on</strong>ably satisfactory to most students and most examiners.<br />

The alternative to accepting an apparent best choice <strong>on</strong> each occasi<strong>on</strong> is<br />

to attempt some more global optimisati<strong>on</strong>, which will either involve astr<strong>on</strong>o-<br />

mical numbers of trials, or some sophisticated c<strong>on</strong>siderati<strong>on</strong>s which are<br />

unlikely to become apparent until after practical experience of a simpler<br />

algorithm. So there is nothing else that can be d<strong>on</strong>e at this stage except hope<br />

for the best.<br />

It remains to program the functi<strong>on</strong>:<br />

functi<strong>on</strong> suitable:sessi<strong>on</strong>,<br />

which selects a suitable sessi<strong>on</strong> from the remaining set of exams. A possible<br />

method of doing this is to generate a number of trial sessi<strong>on</strong> satisfying (4)<br />

(5) and (6), and to select the best <strong>on</strong>e found. The best <strong>on</strong>e will probably be<br />

the <strong>on</strong>e with the largest sessi<strong>on</strong>count, but since we may wish to adjust the<br />

criteri<strong>on</strong> of selecti<strong>on</strong>, it is advisable to define it as a separate subroutine,<br />

updating a variable<br />

bestsofar: sessi<strong>on</strong>;<br />

in accordance with the current value of a variable:<br />

trial: sessi<strong>on</strong>;<br />

procedure record<br />

if sessi<strong>on</strong>count (bestsofar) < sessi<strong>on</strong>count (trial) then<br />

bestsofar: = trial.<br />

The result of suitable is going to be the final value of bestsofar:<br />

suitable: = bestsofar.<br />

It still remains to write a procedure that will generate and record a sequence<br />

of trial sessi<strong>on</strong>s which satisfy (4) (5) and (6). Inspecti<strong>on</strong> of these c<strong>on</strong>diti<strong>on</strong>s<br />

shows that if a trial fails to satisfy <strong>on</strong>e of them, no larger trial will satisfy it.<br />

In other words, having found an impossible trial, there is no need to generate<br />

any further trials which c<strong>on</strong>tain it. This suggests that we organise the<br />

generati<strong>on</strong> process to generate all supersets of each trial that has been found

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

Saved successfully!

Ooh no, something went wrong!