Professional Documents
Culture Documents
Exercise TEST EXAM.1: Consider the graph in Figure 1. It shows a network with ow at top. Find a maximal ow and a minimum cut. Indicate both in the middle respectively lower part of Figure 1. End of Exercise 1 Exercise TEST EXAM.2: Answer the multiple-choice questions in Figure 3. A wrong answers cancels a correct one. Overall you cannot get a negative score. End of Exercise 2 Exercise TEST EXAM.3: Consider the following program: i 0; while (rand(1, 10) = 1) do i i + 1; od print(i); What is the probability that the value 3 is printed? What is the expected value of i that is printed? End of Exercise 3 Exercise TEST EXAM.4: In the bipartite graph shown in Figure 4 indicate the edges of a maximum matching. End of Exercise 4 Exercise TEST EXAM.5: Consider the graph G = (V, E ) in Figure 5. The thick edges form a non-minimum spanning tree T = (V, F ). Find a tree-edge e F and an non-tree-edge e E \ F such that exchanging them gives a minimum spanning tree. That is, the tree T = (v, F ), where F = (F \ {e}) {e } is a minimum spanning tree. Argue why the tree is minimum. End of Exercise 5 1
Exercise TEST EXAM.6: Given a sequence x1 , . . . , xn of integers. Find indices 1 i j n such that the sum
j
xk
k=i
is maximum. That is nd a sub-interval with maximum sum. Example for n = 8 and 5,-2,-6,4,-1,6,-3,2. The maximum sum is 9 and dened by i = 4, j = 6. Describe a Dynamic Programming algorithm for solving this problem and analyse its running time. Hint: Traverse the sequence from left to right. At each position i, there are at most two candidates for the maximum sub-interval in x1 , . . . , xi , (which?). Determine the update rule when moving one position to the right. IF YOU CANNOT FIND A DP-SOLUTION then describe the best (fastest) solution you can think of and analyse its running time. End of Exercise 6
Indicate a minimum cut. The labels at the edges are the capacities.
0/3
a. b. c. d.
Figure 2 shows a ow network and a ow. The ow network in Figure 2 has a minimum cut with value 6. The running time of the Edmonds-Karp algorithm depends on the value of the maximum ow. The residual capacities of a residual network are always less than or equal to the capacities of the corresponding ow network. The longest common subsequence of the strings ACBDDDAB and BBCDADAAB has length 4 The longest common substring of the strings ACBDDDAB and BBCDADAAB has length 3 The union-nd data structure is used in an algorithm for minimum spanning tree (MST) or closest pair (CP)
No No No No
e. f. g.
No No CP
1 2 3 4 5 6 a b c d e
a 5 d 1
1 2
b 3 e
4 c 1 6
2 5
4 3 g h