hw4s - Cs445 - Homework #4 Graphs, MST and Shortest Paths...

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

View Full Document Right Arrow Icon
Cs445 — Homework #4 Graphs, MST and Shortest Paths Due: 4/5/2005 during class meeting. All questions have the same weight. Assume that in all graphs discussed in this homework the number of edges is larger than the number of vertices. In all questions the notation | V | denotes the number of elements in the set V . Also assume that that for each graph G ( V, E ) discussed below, each edge ( u, v ) E is assigned a weight w ( u, v ) which is a real number. In all questions, the length of a path between vertices is the sum of weights of edges along the path, and for two vertices s, v , we denote by δ ( s, v ) the length of the path with minimum weight from s to v . 1. A graph G ( E, V ) is called a cycle graph if there is a path that visits all the edges and all the vertices exactly once, and starts and ends at the same vertex. Suggest an algorithm, as eFcient as possible, for ±nding a Minimum Spanning Tree of a cycle graph. a b c d f e ²igure 1: Example of a cycle graph Answer: Iterate through the set E , and fnd the edge with maximum weight. The graph obtained by removing this edge oF highest weight, will be a MST. Only one edge needs to be removed. IF you remove more than one edge, it no longer remains an MST as atleast one vertex will not be included. The runtime is linear since it takes linear time to fnd the maximum value. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
2. Let G ( V, E ) be an undirected graph. Suggest an algorithm that runs in O ( | E | ) time, and fnds a spanning tree For G (not necessarily a minimum spanning tree). Answer: Solution 1 - ST = φ For each edge e E { if(adding e to ST doesnot introduce a cycle) add e to ST mark e } The test for a cycle can be done in constant time, by marking vertices that have been added to the ST. An edge will introduce a cycle, if both its vertices have already been marked. Solution 2
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/27/2008 for the course CS 445 taught by Professor Williams during the Spring '06 term at Arizona.

Page1 / 6

hw4s - Cs445 - Homework #4 Graphs, MST and Shortest Paths...

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

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