Vous êtes sur la page 1sur 2

Assignment 2

Clark Thomborson
COMPSCI 320 S2 10
17 August 2010

There are a total of 100 marks on this assignment, comprising 5% of your total marks in
this course.
Submission deadline: 5:00pm, Friday 27 August 2010.
You may submit online via Cecil at any time before the deadline. You may also submit
in hardcopy, during working hours, to the dropbox outside my office (303S.595).
There are only two problems in this assignment: text exercises 1.6 and 5.3, on pages 25-6
and 246-7, respectively. For each problem, you are required to specify the inputs, outputs,
input constraints, output constraints, an algorithm, a correctness argument, and a runtime
evaluation. The marking scheme is listed below: each problem is worth 50 marks.
The emphasis in this homework assignment is on developing your skills for expressing a
problem, clearly and precisely, so that it can be solved algorithmically. Note that you will
receive good marks if you are able to transform these two “word problems” from the text
into algorithmic specifications, even if you are unable to design an efficient algorithm that
meets your specifications.

∙ 5 marks. Specify the problem inputs, in commented pseudocode. For example, the first
input for the stable matching problem might be specified as follows.

integer n; // the number of men; also the number of women

∙ 5 marks. Specify the constraints (if any) on the inputs, with a brief indication of
why each constraint can be reasonably assumed to hold for every instance of the given
problem. Example:

// n >= 1, there must be at least one man and woman,


// for otherwise there can be no matching.

∙ 5 marks. Specify the problem outputs, in commented pseudocode. Example:

integer S[1..n]; // a stable perfect matching of men to women,


// where S[i]=j if the i-th man is matched to the j-th woman.

∙ 15 marks. Specify the constraints on the outputs. For example, for the stable matching
problem, the output must be a stable and perfect matching, so you must define the
conditions on S[] which ensure it is a matching, that it is stable, and that it is perfect.

1
To get full credit, your output constraints must be necessary and sufficient to solve
the given problem. If you define the constraints too narrowly (that is, with conditions
that are “sufficient but not necessary”), then you have overconstrained the algorithm,
possibly rendering it infeasible even though the given problem can be feasibly solved. If
you define the conditions too broadly (i.e. necessary but not sufficient) then you have
underconstrained the algorithm, and its output is unreliable as a solution to the given
problem.
∙ 5 marks. Write commented pseudocode for an algorithm which takes the inputs, which
produces outputs of the required form, which meets as many of the output constraints
as possible (under the assumption that the input meets all of its constraints), and which
is efficient. You will get partial credit for producing an algorithm which isn’t efficient,
so if you get “stuck” on this question you should write an exponential-time exhaustive
search algorithm and complete the assignment by answering the next two questions.

∙ 10 marks. Evaluate the correctness of your algorithm: does it meet all constraints?
Explain your reasoning. This need not be a formal proof, but it must be persuasive
and accurate to receive full marks.
∙ 5 marks. Evaluate the runtime of your algorithm, explaining your reasoning. Your
evaluation should include a big-O analysis as well as a brief discussion of whether you
see any possibility that a more efficient algorithm might exist.

Vous aimerez peut-être aussi