This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CSE 260002: Exam 3ANSWERS, Spring 2011 Time: 50 minutes Name: This exam has 4 pages and 10 problems totaling 100 points. This exam is closed book and closed notes. 1. Warshalls algorithm for transitive closure computation is based on dynamic programming which uses the following recursive formula: i,j,k n w [ k ] ij = w [ k 1] ij ( w [ k 1] ik w [ k 1] kj ) Based on the above recursive formula, Warshalls algorithm is written as follows: W = M R ; M R is the 01 matrix for the relation R . For k=1 to n do the following: For i=1 to n do the following: For j=1 to n do the following: w ij = w ij ( w ik w kj ) Let W k be the zeroone matrix produced in the kth. iteration. (a) (5 points) What do the logical operations on the right hand side of the fol lowing statement accomplish in computing the transitive closure? Explain your answer. w ij = w ij ( w ik w kj ) It computes the path ij by connecting paths ik and kj going throug k. (b) (3 points) Give W = M R for the relation { ( b, a ) , ( a, b ) , ( a, c ) } W = M R = a b c a 1 1 b 1 c (c) (6 points) Based on the ordering of the nodes as a, b, c give the matrices W 1 through W 3 as produced by the Warshalls algorithm. W 1 = a b c a 1 1 b 1 1 1 c W 2 = a b c a 1 1 1 b 1 1 1 c 1 W 3 = a b c a 1 1 1 b 1 1 1 c (d) (3 points) Give the run time complexity of the Warshalls algorithm. O ( n 3 ) 2. Following relation is defined on the set A = { 15 , 20 , 29 , 27 } R = { ( a, b ) A A  a b (mod 3) } (a) (5 points) Give the relation R as a set....
View Full
Document
 Spring '08
 SaktiPramanik

Click to edit the document details