100%(10)10 out of 10 people found this document helpful
This preview shows page 144 - 147 out of 147 pages.
Solution:No. The path might leaveS, then come back intoS, then leaveSa second time, thustraversing two edges fromT.Alternative solution:No. Consider the graph below:S={s,a,b,y}is a minimum cut, butthe paths→b→x→y→thas two edges inT(theb→xedge and they→tedge).(b) Consider the graphGshown below. Suppose we want to find the minimum(s,t)-cut(S,V-S)inGsuch that eitherx∈Sory/∈S(i.e., such that(x,y)doesn’t cross the cut in thet→sCS 170, Fall 2014, Final Soln15
direction). This can be done by adding one edge to get a new graphG0, giving the new edgean appropriate capacity, and then finding a minimum(s,t)-cut inG0. Draw below the edgeyou should add to guarantee that this approach will give a correct answer, and label it with itscapacity.saybxdt11111111111Solution:Add an edge fromytoxwith capacity∞(or very large).(c) We want an efficient algorithm for the following problem: given a dagG, source vertexs, andsink vertext, find an unavoidable setUcontaining as few edges as possible.What algorithm design paradigm is most appropriate for this problem?Circle one of thefollowing.(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 inEhave 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.ReturnU={(u,v)∈E:u∈S,v/∈S}.(e) What is the asymptotic running time of your algorithm?Justify your answer concisely (asentence or two should suffice).Solution:Θ(|V| · |E|), since the value of the max flow is at most|V|(at most the number ofedges out ofs).CS 170, Fall 2014, Final Soln16
Comment:Ford-Fulkerson’s running time isΘ(f·|E|), wherefis the value of the maximumflow. In this case, the value of the max flow must be at most|V|(at most the number of edgesout ofs), so we get aΘ(|V|·|E|)running time.Alternatively, we can use the fancy algorithm that can compute the max flow in an arbitrarygraph inO(|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 faras possible. To do this, you havenavailable rockets. Theith rocket is capable of accelerating theship by a rate ofaimeters per second squared and can do this for a total ofsiseconds. The ship isinitially 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 ituntilsiseconds have elapsed, then immediately switch to another unused rocket. Each rocket canonly be used once, and you may ignore the time it takes to switch between rockets.