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

Info icon This 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 efficient as possible, for finding a Minimum Spanning Tree of a cycle graph. a b c d f e Figure 1: Example of a cycle graph Answer: Iterate through the set E , and find 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 find the maximum value. 1
Image of page 1

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

View Full Document Right Arrow Icon
2. Let G ( V, E ) be an undirected graph. Suggest an algorithm that runs in O ( | E | ) time, and finds 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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern