Professional Documents
Culture Documents
COT5405 - Analysis of Algorithms (Fall 2021) Final Exam: Problem 1
COT5405 - Analysis of Algorithms (Fall 2021) Final Exam: Problem 1
Final Exam
Name: Dhanush Pakanati, UFID: 28079405, dpakanati@ufl.edu
December 9, 2021
Problem 1:
Dynamic programming [35]: A thief is robbing a store that has n items. The ith item is worth Vi dollars,
weighs wi pounds and can be grabbed in ti time, where , and are integers. He wants to take as valuable
a load as possible, but he can carry at most W pounds in his knapsack, and can only spend T time
before the police arrive. Which items should he take to maximize the total value? All values involved
are integers.
1. Bellmann Equation:
(
dp[i − 1][j][k]
dp[i][j][k] = (1)
dp[i − 1][j − w[i − 1]][k − t[i − 1]] + dp[i − 1][j][k]
1
3. Provide proof of the algorithm’s correctness.
Claim: The dp[i][j][k] value is calculated correctly for every pair (x,y,z) that occurs
before the set (a,b,c)
Assumption: dp[i][0][0] = dp[0][j][0] = dp [0][0][k] = 0.
Proof: In the algorithm when we consider a item we only have two options. We either
choose it or we do not. Whatever is the case we always take the maximum value from
dp[i-1][w][t] and dp[i-1][j-wi][k-ti]. So, the algorithm always calculate the correct value
of dp[i][j][k].
Proof of Termination: The algorithm is looping over tha values of count(n), weight and
time. Hence, it terminates as soon as every possible index is checked.
The algorithm iterates in 3 for loops over the number of values, weights and times. So
the overall time complexity is in the order of n*W*T.
Time Complexity = O(nWT) where n is number of values, W is maximum weight and
T is maximum time.
2
Problem 2:
Network flow [35]: Given an undirected graph , determine the minimum number of edges that can be
disconnected to partition the graph in such a way that two given vertices are in separate partitions.
Hint: reduce the problem to max flow or one of the variants discussed in class. Make sure you provide
a complete algorithm and indicate a possibly specialized version of max flow that can be used. Indicate
the complexity of this specialized algorithm.
Claim: If C is the number of minimum cuts then the algorithm terminates after finding
at most of C augmenting paths.
Proof of Termination: For every augmentation, as the capacity is 1, the flow increases
by 1. So the maximum number of iterations is equal to the maximum number of paths
found or min number of cuts needed.
Claim: For an un directed graph the minimum number of cuts needed between s and t
is equal to the maximum number of disjoint s-t paths
Proof: In this algorithm the value of maximum s-t flow is equal to the maximum number
of edge-disjoint paths. The removal a set x (subset of E) edges separate s and t then
each s-t path will have at least one edge in the set x. So the number of edge-disjoint
paths are no more than x.
If x be the set of edges that are in the path of A and B with each edge having a capacity
of 1, so the max value of x = v, where v is the value of maximum s-t flow. Hence
removing v edges from G separates and t.
3
3. Find and prove the algorithm’s running time [10].
The running time of augmented graph calculation is O(mc) and the overall time com-
plexity of the ford fulkerson is O(mn). The space complexity of the algorithm is O(m+n).
Where m and n edges and vertices.
4
Problem 3:
Complexity [30]: Problem to consider – given a set of integers , determine if there is a way to partition
the set into two parts in such a way that the sum of the values for each subset is the same. Provide a
complete proof that the problem is NP-complete. Hint: use a reduction to Subset-Sum; make sure you
have all the elements of the proof in place.