Fall 2008
ECE608, Homework #10 Solution
Tuesday, December 9, 2008
(1) CLR 22.16
We are looking for a universal sink i.e., a vertex with in degree of

V
−
1 and out
degree of zero. In the adjacency matrix the elements in row i represent the edges that
our outgoing from node i to other nodes. And the elements in column j represent
the edges that are incoming to node j. We are looking for k, such that the k’th row
has all zero’s and the k’th column has all 1’s except for the element in the k’th row
(which is a zero).
Start traversing the first row and stop at the first 1 that is encountered. This will
take O(V) steps in the worst case. If no 1 is encountered then this row is the only
possible candidate for a universalsink (because it does not have an edge to any other
node, no other node can be a universal sink), we can simply check by traversing the
first column in O(V) time and see if it has all 1’s. If so then node 1 is a universal
sink otherwise the graph has no universal sink. Note that the algorithm terminates
once we find a row of all zero’s whether that row represents a universalsink or not,
thus guaranteeing O(V) running time.
Now say that while traversing the first row we encounter the first 1 at column k. Then
the elements 0 through k1 in the first row have zeros. This means that no node in 0
through k1 can be universalsink’s because node 1 does not have an edge to any of
them. SO we have effectively eliminated k1 nodes from the possible candidates. In
addition we have also eliminated node 1 because its row is not all zero’s. We did this
elimination in O(k) steps by examining the first row.
Now, out of the uneliminated nodes, we begin examining the next available row j
(this may not be the second row of the adjacency matrix) and follow a procedure
similar to the first row. If no 1 is encountered we test the j’th column for 1’s and
terminate as explained above. If a 1 is encountered after m zero’s then againwe have
eliminated m1 nodes plus node j itself from being a universal sink. In total we have
eliminated k+m nodes in O(k+m) time.
Repeating the above procedure, examimining one row at a time those vertices that
have not yet been eliminated, we can find whether a universalsink exists or not. We
will require in the worst case O(V) time before all nodes will have been eliminated.
Thus algorithm is guaranteed to terminate in O(V) time.
(2) CLR 22.26
See Figure 1.
The two child nodes of the root s are both discovered in the first
iteration of BFS. Whichever of the two nodes BFS chooses to traverse first, in the
next iteration both the remaining nodes will become children of that node. Therefore
it is impossible for BFS to obtain the shortest path tree shown in Figure 1.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Figure 1: A graph
G
= (
V, E
) and a corresponding shortestpath tree
G
′
= (
V, E
π
), such
that
G
′
cannot be obtained by running BFS on
G
(3) CLR 22.27
The first step to solve this problem is treat each wrestler as vertex in an undirected
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '11
 PAI
 Graph Theory, Vertex, DFSVisitFindcycle

Click to edit the document details