Solution No The path might leave S then come back into S then leave S a second

Solution no the path might leave s then come back

This preview shows page 144 - 147 out of 147 pages.

Solution: No. The path might leave S , then come back into S , then leave S a second time, thus traversing two edges from T . Alternative solution: No. Consider the graph below: S = { s , a , b , y } is a minimum cut, but the path s b x y t has two edges in T (the b x edge and the y t edge). (b) Consider the graph G shown below. Suppose we want to find the minimum ( s , t ) -cut ( S , V - S ) in G such that either x S or y / S (i.e., such that ( x , y ) doesn’t cross the cut in the t s CS 170, Fall 2014, Final Soln 15
Image of page 144
direction). This can be done by adding one edge to get a new graph G 0 , giving the new edge an appropriate capacity, and then finding a minimum ( s , t ) -cut in G 0 . Draw below the edge you should add to guarantee that this approach will give a correct answer, and label it with its capacity. s a y b x d t 1 1 1 1 1 1 1 1 1 1 1 Solution: Add an edge from y to x with capacity (or very large). (c) We want an efficient algorithm for the following problem: given a dag G , source vertex s , and sink vertex t , find an unavoidable set U containing as few edges as possible. What algorithm design paradigm is most appropriate for this problem? Circle one of the following. (a) Divide-and-conquer (b) Greedy algorithm (c) Dynamic programming (d) Linear programming (e) Reduce to network flow (f) None of the above (d) Show pseudocode for the problem in part (c). (You don’t need to prove your answer correct.) Solution: 1. Make all edges in E have capacity 1. 2. For each edge ( u , v ) E , add the edge ( v , u ) with capacity . 3. Find the max flow in the resulting graph, and let ( S , V - S ) be a minimum ( s , t ) -cut. 4. Return U = { ( u , v ) E : u S , v / S } . (e) What is the asymptotic running time of your algorithm? Justify your answer concisely (a sentence or two should suffice). Solution: Θ ( | V | · | E | ) , since the value of the max flow is at most | V | (at most the number of edges out of s ). CS 170, Fall 2014, Final Soln 16
Image of page 145
Comment: Ford-Fulkerson’s running time is Θ ( f ·| E | ) , where f is the value of the maximum flow. In this case, the value of the max flow must be at most | V | (at most the number of edges out of s ), so we get a Θ ( | V |·| E | ) running time. Alternatively, we can use the fancy algorithm that can compute the max flow in an arbitrary graph in O ( | V |·| E | ) time: Orlin’s algorithm plus the King-Rao-Tarjan algorithm. Problem 16. [Algorithm design: rockets] (7 points) You’re leading an exploration of space, and it is your job to design a spaceship that will go as far as possible. To do this, you have n available rockets. The i th rocket is capable of accelerating the ship by a rate of a i meters per second squared and can do this for a total of s i seconds. The ship is initially at rest (its initial velocity is zero). Your job is to determine the order in which to fire the rockets. You will choose one rocket, fire it until s i seconds have elapsed, then immediately switch to another unused rocket. Each rocket can only be used once, and you may ignore the time it takes to switch between rockets.
Image of page 146
Image of page 147

You've reached the end of your free preview.

Want to read all 147 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture