CPSC 311: Analysis of Algorithms
Information and Review Questions for Exam 2
Spring 2003
General Information
The second exam will be on Thursday April 3.
It will cover material from Chapters 10, 11, 12, 21, 22, and 23 in the text.
It will be a closed book exam (no notes, books, or neighbors)
except you will be allowed a one page cheat sheet (both sides)
which must be turned in with the exam.
There will be 5 or 6 questions worth a total of 100 points.
Remember to show your work  partial credit will be given.
 Review Session:
7:00pm, Tuesday April 1,
Room 113 HR Bright Bldg
Material
All of the following are considered to be fair game:

Reading. Chapters 10, 11 (except 11.5), 12 (except 11.4),
21 (except 21.4), 22 (except 22.5), and 23.

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 #5, #6, and #7.
(The solutions to homework #7 will be available on Tuesday April 1.)

Quizzes.
Understand and know the answers to all the questions on Quizzes 68.
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 #5, #6, and #7 and Quizzes 68;
variations of some of these questions
will appear on the exam.

Data Structures (Chapt 10, 11, 12):
Consider inserting the following keys, in this order, into a
hash table of size m=13.
keys to insert (in this order): 9, 1, 22, 14, 27
 Suppose you use chaining with the hash function
h(k) = k mod 13. Illustrate the result of inserting
the keys above using chaining.
 Suppose you use open addressing with the primary hash function
h1(k) = k mod 13. Illustrate the result of inserting
the keys above using linear probing, i.e.,
h(k,i) = (h1(k) + i) mod 13.
 Suppose you use open addressing with hash functions
h1(k) = k mod 13 and h2(k) = 1 + (k mod 12).
Illustrate the result of inserting
the keys above using double hashing, i.e.,
h(k,i) = (h1(k) + h2(k)*i) mod 13.

Graph Representation, DFS, BFS (Chapt 22):

Disjoint Sets (Chapt 21):
Consider the set of elements U=(1,2, ..., n_{1}).
Give a sequence of
n_{1} makeset operations,
n_{1} union operations, and
n_{2} find operations
that take Theta(n_{1}n_{2}) time when we
use simple unions without path compression (for the
disjointset forest implementation). Explain.
Draw the resulting disjointset forest.
How long does this same sequence of
n_{1} + n_{1} + n_{2}
operations take when we use weightedunions without
path compression (again, with the disjointset forest
implementation)? Explain.
Draw the resulting disjointset forest.
How long does this same sequence of
n_{1} + n_{1} + n_{2}
operations take when we use weightedunions with
path compression (again, with the disjointset forest
implementation)? Explain.
Draw the resulting disjointset forest.

Minimum Spanning Trees (Chapt 23):
Let G=(V,E) be a connected, undirected, weighted graph.
Know the analysis of Kruskal's and Prim's algorithms for finding a
minimum spanning tree.
You should be able to derive the worstcase running times of these
algorithms in terms of both V (number of vertices) and
E (number of edges).
Know the correctness proof of these algorithms.
You should be able to produce these proofs on your own.