See below for the solutions for the second coursework.
See below for the script for the revision lecture.
We have two lectures in week 11 (12/12 - 16/12), namely Monday and
Tuesday (usual time and place): Both lectures serve as revision and
exam preparation.
Information on the past exam-paper for CS-242, 2010/11:
CS-242 was a 20-credit module, while now we have a 15-credit module.
The format of our exam (for 2011/12) is 2 hours, with two out of
three questions (the standard format; the exam for CS-242 was longer).
There is no multiple-choice question anymore. However contentwise
all ten questions from Part A of the 2010/11 exam are relevant.
Question B is in this form not of relevance (we do
divide-and-conquer, but we didn't practise this specific application).
Question C is not of relevance (we don't do network flow anymore).
Question D is of relevance.
See below for the learning goals for the ninth week.
See below for links with more information on our topics.
If you can't make a lab session:
Of course, this can only be an exception.
You need then to do the lab session on our own.
You need also to provide some evidence that you did it.
This must be presented in person either to one of the postgrads,
or you can come to my office.
Either the postgrads or I will then have a little chat about that
lab session's content.
Done that, you sign a piece of paper, and that's it.
But, of course, this must be an exception.
General information
Lectures
Monday 13-14, Glyndwr C
Tuesday 9-10, Glyndwr B
Wednesday 10-11, Grove building, room 330
Thursday 11-12, Wallace Lecture Theatre 218
The first three lectures are regular lectures, while the fourth
(last) lecture is a "tutorial lecture", where the material from the
week is repeated and deepened. Of course, also this lecture is
compulsory.
Know how best-case and worst-case examples look like, and how
many comparisons they need for sorting (at least in terms of Theta).
Know the basic functions b^x, log_b(x), log_2(x) = lg(x), and floor
and ceiling.
And recall the summation symbol (big Sigma).
Week 2:
Big-Oh, Omega and Theta.
Know the definitions.
Know basic examples.
More examples to come in the rest of the module.
Divide-and-Conquer:
Understand the basic principle.
More examples to come in the rest of the module.
Min-Max Algorithm:
Understand the naive algorithms and why it takes 2n-2 comparisons.
Understand the idea for the divide-and-conquer version.
Understand the Min-Max recurrence.
Week 3:
Understand Merge-Sort and its analysis.
Understand the basic idea for recurrences.
Know the Master theorem, and how to apply it.
Understand the basic idea for the faster matrix-multiplication
algorithm.
Week 4:
There are various important notions and concepts
to learn.
This means at least that you know (can reproduce) the (precise)
definition, where you understand all the terms in the definition,
and that you can give examples.
The notions are:
"Graphs", "undirected" and "directed" ("digraphs")
"Vertices" and "edges" resp. "arcs" (directed edges)
"Trees" (free ones) and "rooted trees"
"Spanning trees" and "rooted spanning trees"; also "spanning
forests"
The "root", the "leaves" and the "children" of a "node" in a
rooted tree
"Paths" in graphs and digraphs
"Connected graphs"
"Cycles" in graphs and digraphs
Connected graphs without cycles are trees, digraphs without cycles
are "directed acyclic graphs" ("dags").
Know the two main representations of graphs and digraphs (adjacency
lists and adjacency matrices).
The first main algorithm is BFS:
When the input is a connected graph and a vertex s, the output is
is rooted spanning tree (with root s), which contains shortest paths
from the root to all other vertices (shortest, of course, in the full
graph), plus the distance map.
One can also run it on a digraph, and one can also restart it
so that it covers the whole (possibly disconnected) graph.
The output then is a collection of rooted trees, containing
shortest paths from the respective root to all other reachable
vertices.
The second main algorithm is DFS:
Here the input is already assumed as a possibly disconnected graph,
and the output is a DFS-forest, consisting of rooted spanning trees
for the connected components, plus the assignment of discovery and
finishing times for all vertices.
Again, we can run it on a digraph.
The application we considered is for topological sorting.
Week 5:
Know and understand the abstract data type ("API") "dynamic set":
What are the basic operations?
What are "keys"? Which operations do we assume for them?
What is the simplest implementation? What are the disadvantages?
What are "dictionaries" and "priority queues" (in this context)?
Understand the chain of notions
tree
rooted tree
ordered rooted tree
binary tree
binary search tree.
Understand the representation of binary trees.
Understand the inorder traversal for binary trees.
Understand how the order requirement for a binary search tree
interacts with the inorder traversal.
Understand how to search for a key in a binary search tree, and
what the complexity of this operation is.
Understand the computation of minimum and maximum in binary search
trees, and the complexity of these operations.
The same for the computation of predecessors and successors.
Understand the idea and the algorithm for insertion.
Understand the ideas for deletion.
Understand the topic of "bad orders" ("they are possible, but
unlikely").
Week 6:
Understand the abstract data type underlying "disjoint sets":
What are the basic operations?
What are the "representatives"?
When are elements given, when pointers?
Computation of connected components as application:
Know what "connected components" are.
Understand how to compute connected components by the
disjoint-sets data structure.
Linked-list representation of disjoint sets:
Know what a node of this representation looks like.
Understand how the nodes are linked together to build the
data structure.
Understand how the three basic operations operate on this
data structure, and what their costs are.
Runtime analysis:
Understand the two main parameters, n and m.
Understand the idea of "amortised analysis".
Understand the nasty example for the linked-list representation
(without any heuristics).
Weighted-union heuristics:
Understand the problem and the idea.
Know the theorem about the worst-case upper bound achieved by this
heuristics.
Know and understand the proof of the theorem.
Forest representation of disjoint sets:
Understand the idea.
Understand which of the basic operations become faster, which
slower.
Understand the two basic heuristics for improving the efficiency
of the forest representation.
Know the runtime achieved by using both.
Week 8:
Understand the problem of making change, and how a greedy approach
is invoked here.
It should be not too hard for you to come up with a coin denomination
where the greedy approach fails.
Understand the general idea of a "greedy approach".
Minimum spanning trees:
Know the definition of an MST.
You should be able to exhibit some MST for small examples
yourself (just by looking at it).
Understand Kruskal's algorithm (as a special greedy algorithm).
Understand how it involves disjoint sets.
Get a general idea when greedy algorithms work; try to grasp the
criterions given.
Huffman codes:
Understand the general problem of compressing a text file via
a binary code.
Understand how binary prefix codes are presented by binary
trees.
Understand that some codes are more efficient than others.
Understand the Data Compression Problem.
Understand the greedy algorithm for computing a "Huffman code".
You need to be able to apply this algorithm to examples.
Week 9:
Understand the precise (and general) algorithmic solution for
Making Change via dynamic programming.
Of central importance here is the recurrence relation for the
two-dimensional array c, and how to compute it.
Also understand how, after having determined the optimal numbers
of coins, one can determine which coins actually to use.
You should be able to run the algorithm on paper for examples.
Understand the complexity analysis of the algorithm.
Know the general characterisation of the dynamic programming
strategy.
Know the All-pairs Shortest Paths problem.
Know the Floyd-Warshall algorithm, especially its recurrence
relation.
Know its time and space complexity.
Week 10:
Know what a "decision problem" is (input a binary string, output
"0" or "1" (or "No" resp. "Yes")).
Understand intuitively the two main complexity classes:
P ("polynomial time")
NP ("nondeterministic polynomial time" --- a guessed solution can
be verified in polynomial time).
Know examples for problems in NP.
Understand intuitively the notion of "NP-completeness" (a (decision)
problem is NP-complete iff it is in NP and every other problem in NP can
be reduced to it).
The central NP-completeness is the "SAT problem":
Know "CNF" (conjunctive normal form).
Understand how logical puzzles can be expressed as SAT problems.
Know how to express graph-colouring problems as SAT problems.
Regarding graph-colouring:
The decision problem is called "k-colouring", for some fixed
natural number k.
The 3-colouring problem (decide whether a graph is 3-colourable or
not) is NP-complete.
While the 2-colouring problem can be decided in polynomial time.
Coursework
General rules
The two assignments are to be done in pairs (as in the lab classes)
using the following algorithm:
Each one of you produces solutions to the assignment questions
independently.
Then, and only then, do you compare your solutions to your partner's
solutions, and you try to convince each other of the correctness of your
own solutions.
In the process, you help each other clarify the difficulties you are
having with the material.
Finally, each of you writes up the solution on his/her own.
You must indicate name and student number of your partner clearly on
your solution.
This procedure is used, as the assignments will all be
paper-and-pencil exercises, typically requiring a degree of
contemplation.
You will not be writing any programs, so you will not get
any mechanical feedback (compiler errors, erroneous output) indicating
that your solutions are incorrect.
Your partner will act as an independent reviewer to
identify your "compile-time" and "run-time" logical errors.
See
here
for information on how to submit the coursework.