CPSC 221H: Data Structures & Algorithms
Information and Review Questions for Exam 3
Spring 2009
General Information
The third exam will be on Friday May 8, 2009 from 3pm-5pm in the classroom
(during the final exam slot).
The third exam will cover material from
Chapters 10 and 12 in the text.
It will be a closed book exam (no notes, books, or neighbors)
except you will be allowed a one page (8.5x11), two-side
cheat sheet which must be turned in with the exam.
There will be 5 questions, each worth 20 points, for 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 10 (except 10.4, and mainly 10.7)
and
12 (except 12.4.2, 12.4.3, 12.4.4) in the text.
-
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-11.
-
Quizzes.
Understand and know the answers to all the questions on Quizzes 8-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-11, Quizzes 8-11, and the in class assignments;
variations of some of these questions
will appear on the exam.
-
Sorting and Selection.
Consider the following comparison-based sorting algorithm.
New-Sort(array L of integers)
if (L has more than 1 element)
x := Magic-Median(L); /* find median element in L */
Magic-Partition(x,L); /* partition around median x */
New-Sort(1st half of L);
New-Sort(2nd half of L);
endif
return L;
end /*New-Sort*/
-
Assume that Magic-Median always returns the median element of L
and that it runs in time O(1).
Assume also that Magic-Partition(x,L) runs in time O(1).
Derive and solve the recurrence relation for the
asymptotic running time of New-Sort;
clearly state any assumptions you make.
-
Assume that Magic-Median always returns the median element of L
and that it runs in time O(1).
Assume also that Magic-Partition(x,L) runs in time O(|L|).
Derive and solve the recurrence relation for the
asymptotic running time of New-Sort;
clearly state any assumptions you make.
-
Design an algorithm for the selection problem that is derived from
New-Sort. Repeat the two problems above for your selection algorithm.
-
Graph Representation and traversal.
-
Given an adjacency list representation of a directed graph, how long
does it take to compute the out-degree of every vertex?
How long does it take to compute the in-degree of every vertex?
(The out-degree of a vertex is the number of edges leaving it,
and the in-degree is the number of edges entering it.)
Repeat the above analysis assuming the graph is represented by
an adjacency matrix.
-
Give an algorithm for determining if a graph G=(V,E) has an
isolated vertex (a vertex with no adjacent edges).
What is the worst-case running time of your algorithm in terms
of V (number of vertices) and E (number of edges) if
G is represented by an adjacency list? What if G is
represented by an adjacency matrix?
-
Minimum Spanning Trees (MSTs).
Let G=(V,E) be a connected, undirected, weighted graph.
Know Kruskal's, Prim-Jarnik's, and Baruvka's algorithms for MSTs.
-
Be able to show how the algorithms would work on a given graph.
Know when they can or cannot be applied.
-
Know the analysis of these algorithms.
Given the pseudo-code of these algorithms,
you should be able to derive the worst-case running times of these
algorithms in terms of both V (number of vertices) and
E (number of edges).
-
Be able to prove the algorithms are correct.
-
If you were going to design parallel algorithm for the MST
problem, which of these three algorithms would you start with,
and how would you parallelize it? What would be the running time?
-
Shortest Paths.
Know Dijkstra's and Bellman-Ford
single-source shortest path (SSSP) algorithms.
Also, know the topological sort-based SSSP algorithm that can
be applied to DAGs.
-
Be able to show how the algorithms would work on a given graph.
Know when they can or cannot be applied.
-
Know the analysis of these algorithms.
Given the pseudo-code of these algorithms,
you should be able to derive the worst-case running times of these
algorithms in terms of both V (number of vertices) and
-
Be able to prove the algorithms are correct.