CSE373 Homework2.pdf

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

• Homework Help
• 5

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

CSE373 Homework2 Sangtian Wang , 111578610 I discussedHW2 with Zhengwei Wei, Liam Wang. 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: semsters = 0 ; S = { v in V | v has no incoming edge }; while ( S is not empty ){ cur_course = S . size (); 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 ;

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

The complexity is O(V+E), which is linear in G. 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.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern