# hw8 - Solution to Homework 8 Com S 311 Apr 1 2003 1...

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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Solution to Homework 8 Com S 311 Apr 1, 2003 1 Exercise 22.1-1 (P. 538, 4 points, grader: Yu Cao) The running result of DFS(3) is displayed as following: Table 1: The d and π V ertex d π 1 N ull N ull 2 3 4 3 N ull 4 2 5 5 1 3 6 1 3 2 Exercise 22.2-6 (P. 539, 6 points, grader: Yu Cao) 1. we can apply BFS to solve this problem. In order to apply the BFS algorithms, we need to configure a graph. Suppose the wrestlers as the vertices of the graph. Suppose the rivalry between two wrestlers as the edge of the graph. 2. Once we generate a graph to represent the relation among wrestlers, we convert this problem into a bipartite graph problem. 3. The algorithms is listed as following: • Start from one of the vertex, run BFS from this vertex. 1&#13; 4&#13; 5&#13; 2&#13; 3&#13; 6&#13; Figure 1: BFS tree 1 • During the running procedure of BFS, check the node in each level. If there are both ”Good guy” and ”Bad guy” in the same level. We can say it’s impossible to designate some of the wrestlers as good guys and the remainder as bad guys such that each rivalry is between a good guy and a bad guy. Otherwise it’s possible. 3 Prolbem 22.2-7 (8 points, grader: Fangcheng Tang) Solution: Run BFS on any node s in the graph, remembering the node u discovered last. Run BFS from u remembering the node v discovered last . δ ( u, v ) is the diameter of the tree. Correctness: let a and b be any two nodes such that δ ( a, b ) is the diameter of the tree.There is unique path from a to b . Let t be the first node on that path discovered by BFS....
View Full Document

## This note was uploaded on 10/04/2010 for the course COMPUTER 531 taught by Professor A during the Spring '10 term at Abraham Baldwin Agricultural College.

### Page1 / 5

hw8 - Solution to Homework 8 Com S 311 Apr 1 2003 1...

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

View Full Document
Ask a homework question - tutors are online