CPSC 311: Analysis of Algorithms
Information and Review Questions for Exam 3
Spring 2003
General Information
The third exam will be during the final exam times, which are different
for the two sections:
- CPSC 311-501 (TR 2:20-3:35pm): Wednesday May 7, 1:00-3:00pm
- CPSC 311-502 (TR 9:35-10:50am): Friday May 2, 12:30-2:30pm
It will cover material from Chapters 24, 25, 15, 34, and 35 in the text.
It will be a closed book exam (no notes, books, or neighbors)
except you will be allowed a one page, two side cheat sheet which must
be turned in with the exam.
There will be 5 questions worth a total of 100 points.
Remember to show your work - partial credit will be given.
Material
All of the following are considered to be fair game:
-
Reading. Chapters 24, 25 (only 25.2), 15 (except 15.5),
34 and 35 (only 35.1 and 35.2).
-
Lectures. You are responsible for things that we went over that
were either not covered in the text, or that were done differently than
in the text.
-
Homeworks.
Know how to do all the problems on homeworks #8, #9, and #10;
the solutions to homework #10 will be available after 5pm
Monday April 28.
-
Quizzes.
Understand and know the answers to all the questions on Quizzes 9-11.
Review Questions
Below are some suggested review exercises/problems for the exam.
It is strongly recommended that you be able to do all of these
problems. Solutions will not be handed out.
Finally, be sure to check your email -- clarifications
and/or explanations will be mailed to the class if needed.
-
Study Homeworks #8-10 and Quizzes 9-11;
variations of some of these questions
will appear on the exam.
-
Shortest Paths (Chapt 24, 25):
Know Dijkstra's single-source shortest path (SSSP) algorithm and the
Floyd-Warshall all-pairs shortest paths (APSP) algorithm.
Know their running times, and when they can and cannot be applied.
Give a simple example of a directed graph with negative weight
edges for which Dijkstra's algorithm produces incorrect
answers. Use this example to explain why the proof of correctness
for Dijkstra's algorithm doesn't go through when negative weight
edges are allowed.
In some cases, one can solve the APSP problem using V
applications of Dijkstra's algorithm (one for each node of G).
Give a simple example of a case when this won't work, but when
the Floyd-Warshall algorithm can be used to solve the APSP problem
correctly.
-
Dynamic Programming (Chapt 15):
Study the dynamic programming technique.
Know when it would be a good solution technique and when it would not.
Study the dynamic programming applications we covered
in class (Floyd-Warshall and matrix multiplication order),
or in homework (e.g., problem 15-6 in the text).
-
Dynamic Programming (Chapt 15):
A carpenter has a piece of wood of a certain length that must be
cut at positions a1, a2 ..., an
where ai is the distance from the left end of the
original piece of wood. Notice that after making the first cut, the
carpenter now has two pieces of wood; after making the second cut,
the carpenter has three pieces of wood, etc.
Assume that the cost of making a cut in a piece of wood of
length l is equal to l, and is the same no matter
which position in that piece of wood is being cut.
Let L be the length of the original piece of wood.
First, derive the recurrence relation which could be used to design
a recursive algorithm to find the minimum total cost for making all
the cuts.
Second, describe a top-down recursive dynamic programming
algorithm to find the minimum total cost for making all the cuts that
minimizes the total cost. Analyze the worst-case running
time and storage requirements of your algorithm.
Third, describe a bottom-up recursive dynamic programming
algorithm to find the minimum total cost for making all the cuts
adn the order in which to make the cuts that minimizes the total
cost. Analyze the worst-case running time and storage requirements
of your algorithm.
-
NP-Completeness and Approximation Algorithms (Chapt 34, 35):
Know and understand definitions of the classes P, NP, NP-Complete.
Know and understand what it means for one problem to be
transformable to another problem in polynomial time.
Know and understand how you would prove that a problem is
NP-Complete (using polynomial time transformations).
Know what an approximation algorithm is, and when one
might be useful.
-
NP-Completeness and Approximation Algorithms (Chapt 34, 35):
The Hamiltonian Path (HP) problem is, given an undirected graph
G=(V,E), does there exist a path in the graph that visits
every node in V exactly once?
The Hamiltonian Circuit (HC) problem is, given an undirected graph
G=(V,E), does there exist a cycle in the graph that visits
every node in V exactly once?
The Longest Circuit (LC) problem is, given a weighted undirected
graph G=(V,E) and a bound B,
does there exist a cycle in G whose weight is at least
B?
- Show that HP, HC, and LC are in NP.
- Assuming that the HC problem is NP-Complete, prove that the
Traveling Salesman problem is NP-Complete.
- Assuming that the HC problem is NP-Complete, prove that the
LC problem is NP-Complete. (Hint: a HC has exactly n edges,
where n is the number of vertices in G.)
-
NP-Completeness and Approximation Algorithms (Chapt 34, 35):
Consider the following three problems (defined in class and in
the text):
Independent Set (IS),
Vertex Cover (VC),
Clique.
- Assuming that the Vertex Cover (VC) problem is NP-Complete,
show that the Independent Set (IS) problem is NP-Complete.
- Assuming that the Independent Set (IS) problem is NP-Complete,
show that the Clique problem is NP-Complete.
- Assuming that the Vertex Cover (VC) problem is NP-Complete,
show that the Clique problem is NP-Complete.