Question: Problem 7 : Dynamic Programming The following problem can be useful for data compression. The input is a string s of length n and a

Problem 7: Dynamic Programming
The following problem can be useful for data compression. The input is a string s of length n and a list of k strings x1,dots,xk of lengths m1,dots,mk respectively. The problem is to determine the smallest number of copies of strings from x1,dots,xk that can be concatenated together to produce s.(you can use as few or as many copies of each string as you want)
For example, if S=bababbababa,x1=a,x2=ba,x3=abab, and x4=b, then we can write s=x4x3x2x3x1 which is optimal, so the answer is 5.
(a) For i0, let Opt(i) be the optimal number of strings required to produce the string s[1:i], meaning the prefix of s of length i. Describe a recursive algorithm for computing Opt(n). Don't forget the base case.
(b) Describe how you can compute Opt(n) efficiently without recursion, using a dynamic programming algorithm.
(c) Let m be the maximum for mi for all i. What is the running time of your algorithm in terms of n,k and m ?
Problem 7 : Dynamic Programming The following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!