CSE373 Homework2_wired.pdf

CSE373 Homework2_wired.pdf - CSE373 Homework2 Sangtian Wang...

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

View Full Document Right Arrow Icon
CSE373 Homework2 Sangtian Wang , 111578610 Solution 1 Answer: and have same topology and di ff erent weight of edges: . We can know that the order of weights are same for and . Assume we use Prim or Kruskal Algorithm to fi nd the MST, all the steps are the same for and . So the minimum spanning trees of and are the same, i.e. . Solution 2 The idea is to fi nd the topology of , which should be a DAG, and record the layers of . Algorithm: The complexity is O(V+E), which is linear in G. semsters = 0 ; S = { v in V | v has no incoming edge }; cur_course = S . size (); while ( S is not empty ){ semsters = semsters + 1 ; pre_course = []; while ( cur_course > 0 ){ y = S . head (); for ( each y s . t . ( x , y ) in E ){ \\x is the prerequisite course of y E = E - ( x , y ); if ( x has no incoming edge ) pre_course . insert ( y ); } cur_course = cur_course - 1 ; } S = pre_course ; } return semsters ;
Image of page 1

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

View Full Document Right Arrow Icon
Solution 3 Algorithm: Runnint time: when n>1 when n=1 Thus: Solution 4 Let for all , then we just need to fi nd the minimum spanning tree of . And this tree is the answer we want.
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