6. [Min Element Sum.] Consider the following problem, MinElement Sum. MinElementSum(n,S): Let S be a set of positive int
Posted: Sat Nov 27, 2021 2:29 pm
(a) Argue that for S = {1, 2}, your friend's algorithm has exponential running time. (That is, running time of the form 287(n)). You may assume that Fibonacci numbers grow exponentially, i.e., let f(n) be a function that returns n-th Fibonacci number, you may assume that f(n) = 232(7) We are expecting: • A recurrence relation that the running time of your friend's algorithm satisfies when S = {1, 2} A convincing argument that the closed form for this expression is 28(m). You do not need to write a formal proof. ] (b) Turn your friend's algorithm into a top-down dynamic programming algorithm. Your algorithm should take time O(ns). Hint: Add an array to the pseudoco de above to prevent it from solving the same sub-problem repeatedly. [We are expecting: • Pseudocode AND a short English description of the idea of your algorithm. An informal justification of the running time. (c) Turn your friend's algorithm into a bottom-up dynamic programming algorithm. Your algorithm should take time O(ns). Hint: Fill in the array you used in part (b) iteratively, from the bottom up. [We are expecting: • Pseudocode AND a short English description of the idea of your algorithm • An informal justification of the running time.