Solutions to hw06 in CS 31, F15
Solution to Exercise 23.1-5
Let T be an MST of G. If edge e is not in T then we are done. If e
is in T remove it, separating T into two subtrees T1 and T2 . Some other
edge e of the cycle c that has e as a maximum-weight ed

Solution to Exercise 17.4-3
We are to maintain our dynamic tables by doubling their size when
expanding a full table and multiplying its size by 2/3 when the tables load
factor drops below 1/3. We are to show that the amortized time of TableDelete is cons

Solutions to hw07 in CS 31, F15
Solution to Problem 26-1
a) To convert a network with vertex and edge capacities to a network with
only edge capacities we replace each vertex by a pair of vertices. Replace
each vertex v V with capacity cv by two vertices,

Sample Solution to the Midterm Exam for CS 31
Prof. Drysdale
October 21, 2015
Problem 1: (20 points)
You work for an online ski shop. People order skis, and your job is to package them up and ship
them. To protect the skis each is shipped in a ski bag. Th

Solution to Exercise 15.4-4
This solution is also posted publicly
When computing a particular row of the c table, no rows before the previous row
are needed. Thus only two rows2 Y:length entriesneed to be kept in memory
at a time. (Note: Each row of c act

Solution to Exercise 8.1-3
This solution is also posted publicly
If the sort runs in linear time for m input permutations, then the height h of the
portion of the decision tree consisting of the m corresponding leaves and their
ancestors is linear.
Use th

Solution to Exercise 16.1-3
For the approach of selecting the activity of least duration from those that are
compatible with previously selected activities:
i
si
fi
duration
1
0
3
3
2
2
4
2
3
3
6
3
This approach selects just fa2 g, but the optimal solutio

Solution to Exercise 3.1-1
First, let’s clarify what the function max( f (n), g(n) is. Let’s deﬁne the function
li(n) = max(f(n), g(n). Then
f0!) iff(n)2s(n),
so?) if f (n) <g(n).
Since f (n) and 301) are asymptotically nonnegative, there exists no such t