hw10s.f11 - Fall 2008 ECE608, Homework #10 Solution...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Fall 2008 ECE608, Homework #10 Solution Tuesday, December 9, 2008 (1) CLR 22.1-6 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 out-going from node i to other nodes. And the elements in column j represent the edges that are in-coming to node j. We are looking for k, such that the kth row has all zeros and the kth column has all 1s except for the element in the kth 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 universal-sink (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 1s. 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 zeros whether that row represents a universal-sink 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 k-1 in the first row have zeros. This means that no node in 0 through k-1 can be universal-sinks because node 1 does not have an edge to any of them. SO we have effectively eliminated k-1 nodes from the possible candidates. In addition we have also eliminated node 1 because its row is not all zeros. We did this elimination in O(k) steps by examining the first row. Now, out of the un-eliminated 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 jth column for 1s and terminate as explained above. If a 1 is encountered after m zeros then againwe have eliminated m-1 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 universal-sink 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.2-6 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....
View Full Document

This note was uploaded on 01/10/2012 for the course ECE 565 taught by Professor Pai during the Fall '11 term at Purdue University-West Lafayette.

Page1 / 9

hw10s.f11 - Fall 2008 ECE608, Homework #10 Solution...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online