Dijkstra's Algorithm - Efficient Algorithms and Intractable Problems - Exams, Exams of Algorithms and Programming

Main points of this exam paper are: Dijkstra'S Algorithm, Network Flows, Fulkerson Algorithm, Residual Network, Augmenting Paths, Augmentation Step, Numerical Value, Maximum , Ow, Minimum Cut

Typology: Exams

2012/2013

Uploaded on 04/02/2013

sushmi_98
sushmi_98 🇮🇳

4.5

(4)

51 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 170
Spring 2000 Midterm #2 Demmel / Shewchuk
This is a closed book, closed calculator, closed computer, closed network, open brain exam, but
you are permitted a one-page, double-sided set of notes.
Write all your answers on this exam. If you need scratch paper, ask for it, write your name on each
sheet, and attach it when you turn it in (we have a stapler).
Do not open your exam until you are told to do so!
Page 1
pf3
pf4
pf5

Partial preview of the text

Download Dijkstra's Algorithm - Efficient Algorithms and Intractable Problems - Exams and more Exams Algorithms and Programming in PDF only on Docsity!

Spring 2000 Midterm #2 Demmel / Shewchuk

This is a closed book, closed calculator, closed computer, closed network, open brain exam, but you are permitted a one-page, double-sided set of notes.

Write all your answers on this exam. If you need scratch paper, ask for it, write your name on each sheet, and attach it when you turn it in (we have a stapler).

Do not open your exam until you are told to do so!

Spring 2000 Midterm #2 Demmel / Shewchuk

  1. (12 points) Network Flows In the flow network illustrated below, each directed edge is labeled with its capacity. We are using the Ford-Fulkerson algorithm to find the maximum flow. The first augmenting path is S-A-C-D-T, and the second augmenting path is S-A-B-C-D-T.

(a) (6 points) Draw the residual network after we have updated the flow using these two augmenting paths (in the order given).

(b) (4 points) List all of the augmenting paths that could have been chosen for the third augmentation step.

(c) (2 points) What is the numerical value of the maximum flow? Draw a dotted line through the original graph to represent the minimum cut.

Spring 2000 Midterm #2 Demmel / Shewchuk

  1. (12 points) NP-Completeness We know that max-flow problems can be solved in polynomial time. However, consider a modified max-flow problem in which every edge must either have zero flow or be completely saturated. In other words, if there is any flow through an edge at all, the flow through the edge is the capacity of the edge. Let’s call a flow a saturated flow if it satisfies this additional constraint, as well as all the usual constraints of flow problems. The modified problem asks us to find the maximum saturated flow. (a) (1 point) Formulate this problem as a decision (yes/no) problem. (We’ll call it MAX- SATURATED-FLOW.) Write your answer in the form of a question.

(b) (3 points) Show that MAX-SATURATED-FLOW is in NP.

(c) (8 points) Show that MAX-SATURATED-FLOW is NP-hard. Hint: the easiest reduction is not from one of the NP-complete graph problems you know. What other NP-complete problems do you know?

Spring 2000 Midterm #2 Demmel / Shewchuk

  1. (15 points) Dynamic Programming Consider the Maximum Alternating Sum Subsequence (MASS) problem. Given a sequence S = [x 1 , x 2 ,... , xn] of positive integers, find the subsequence A = [xi 1 , xi 2 ,... , xik ], where i 1 < i 2 < · · · < ik, that maximizes the alternating sum xi 1 − xi 2 + xi 3 − xi 4 + · · · ± xik.

For example, if S = [4, 9 , 2 , 4 , 1 , 3 , 7], the MASS is A = [9, 2 , 4 , 1 , 7] which evaluates to 9 − 2 + 4 − 1 + 7 = 17. If S = [7, 6 , 5 , 4 , 3 , 2 , 1], the MASS is A = [7]. Clearly, the length of the MASS depends on the actual values in S. Assume that the length of S is at least one, and all its elements are integers greater than zero. The following questions ask you to develop a dynamic programming algorithm to find the value of the MASS (but not the actual subsequence) for a given sequence. We would like a solution with optimal running time, but you will only lose a few points if you have a correct, suboptimal algorithm. (a) (3 points) Describe the subproblems you will need to solve. How many tables (of sub- problem solutions) do you need? What is the dimension of the table(s)? What do the table entries represent? (Hint: it helps to treat subsequences of even and odd lengths separately.)

(b) (7 points) Write a recursion for the values your algorithm will fill into the table(s). Also write the base case(s); i.e. the table value(s) that bootstrap(s) the recursion.

(c) (4 points) Write iterative, non-recursive pseudocode for your algorithm.

(d) (1 point) What is the running time of your algorithm?