Homework Assignment Due in class, 4/22
- 21.3-1, but use size rather than rank during union. In case of
two sets with the same size of calls to union(x,y), the first item's
set representative the combined representative. (So here, x's initial
set will be the root of the combined set if x and y sets have the same
size.)
- 22.4-1
- For the same graph as above, run the other topological sort
algorithm we saw in class. To remind you: the algorithm first
calculates the in-degrees of all vertices as the number of
"preconditions" for each vertex. Next, enqueue all
vertices of in-degree 0. While the queue is not empty, dequeues
the next item from the queue, and decrement the number of
preconditions of the vertices the current vertex has an outgoing edge
to. If that number becomes 0, enqueue the appropriate vertex. The
order of vertices into/out of the queue is the topological ordering.
(Note, this method is not given in the book, but is outlined in
problem 22.4-5. We covered it in class.)
- 22.4-3
- 22.5-2
- 22.5-3
- 22.5-7 (think)