HW8 - I 1 2 C 1 2 S I 3 1 I 2 3 C 1 2 S Sample Output: no...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 p.280 8.7 A formatted version We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from o Input: Input consists of several test cases. For each test case, the first line contains N (<=10,000), the total number of computers in a network. Each computer in the ne t w Then in the following lines, the input is given in the format: I c1 c2 where I stands for inputting a connection between c1 and c2 C c1 c2 where C stands for checking if it is possible to transfer files between c1 and c2 S where S stands for stopping this case. Output: For each C case, print in one line the word "yes" or "no" if it is possible or impossible to transfer files between c1 and c2, resp e At the end of each case, print in one line "The network is connected." if there is a path between any pair of computers Print a blank line between test cases. Sample Input: C 1 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

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

Unformatted text preview: I 1 2 C 1 2 S I 3 1 I 2 3 C 1 2 S Sample Output: no yes There are 2 components. yes The network is connected. Note: Must use union-by-size and path compression. p.337 9.2 If a stack is used instead of a queue for the topological sort algorithm in Section 9.1, does a different ordering result? Why mi g p.337 9.5 a. Find the shortest path from A to all other vertices for the graph in Figure 9.80. b. Find the shortest unweighted path from B to all other vertices for the graph in Figure 9.80. Sheet1 Page 2 p.338 9.10 a. Explain how to modify Dijkstra's algorithm to produce a count of the number of different minimum paths from v to w. b. Explain how to modify Dijkstra's algorithm so that if there is more than one minimum path from v to w, a path with the fewes Sheet1 Page 3 or or or &quot;There are k components.&quot; where k is the number of connected components in this network. Sheet1 Page 4...
View Full Document

This note was uploaded on 02/16/2011 for the course CS 136 taught by Professor Yuechen during the Winter '08 term at Zhejiang University.

Page1 / 4

HW8 - I 1 2 C 1 2 S I 3 1 I 2 3 C 1 2 S Sample Output: no...

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

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