# mid2sol - COT 5405 Analysis of Algorithm Mid-term Exam II...

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

COT 5405 Analysis of Algorithm Mid-term Exam II Solution Problem 1(30pts) . Given an undirected simple weighted graph G = ( V, E ) (having no self-loops or multi-edges) with two designated vertices s, t V and weight w e (unnecessarily positive) for any edge e E . A path p s,t is said to be shortest from s to t if the aggregate weight of p s,t , defined as c ( p s,t ) = edge e p s,t w e , is the smallest among all paths from s to t . A second smallest path is a path p s,t with c ( p s,t ) c ( p s,t ) and contains at least one different edge from p s,t , while c ( p s,t ) c ( q ) for any other s t path q . 1. (15pts) Design an algorithm to find such a second smallest s t path. Please describe your algorithm and sketch its correctness. Pseudocode is NOT required. 2. (15pts) Two (or more) paths are edge-disjoint if they have no edges in common. The K shortest Edge- Disjoint Path Problem is to find the shortest, 2 nd shortest, · · · , K th shortest s t paths which are Edge-Disjoint. Design an algorithm to find these K paths. Please describe your algorithm and sketch its correctness. Pseudocode is NOT required. ( HINT: translate this into a ﬂow problem. ) 3. ( Bonus 10pts) Two (or more) paths are node-disjoint if they have no common intermediate nodes. Design an algorithm to find the K shortest Node-Disjoint Paths. Please describe your algorithm and sketch it- s correctness. Pseudocode is NOT required. ( HINT : Convert to K shortest Edge-Disjoint Path Problem.) Solution : Note that simple graph is a graph with no self -loop or multiple edges. Directed or undirected simple graphs have the same solution for this question. (1) Use a similar idea of Floyd-Warshall algorithm. Step 1 : Use Floyd-Warshall algorithm to find the shortest paths from s to all v V and those from all v V to t in O ( | V | 3 ) time. Denote the shortest path between i and j as π 1 ( i, j ). Initialize the second shortest path as π 2 ( i, j ) with length ( π 2 ( i, i )) = 0 and length ( π 2 ( i, j )) = for i ̸ = j . Step 2 : For every edge ( x, y ) E Let the path tmp ( s, t ) be the concatenation: π 1 ( s, x ) , ( x, y ) , π 1 ( y, t ) if ( tmp ( s, t ) is not shorter than π 1 ( s, t ) and with at least one different edge from π 1 ( s, t )) && ( tmp ( s, t ) is shorter than π 2 ( s, t )) π 2 ( s, t ) = tmp ( s, t )

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.

{[ 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