Question: Problem 2 . Solving equations ( 1 0 points ) Describe an algorithm ( using DP . Format is given below. ) that takes as

Problem 2. Solving equations (10 points)
Describe an algorithm (using DP. Format is given below.) that takes as input four positive integers a,b,c and D, and outputs non-negative integers x,y,z that approximately solves ax+by+cz~~D. Specifically, you should find x,y,z such that ax+by+cz is as close to D as possible (either lower or higher).
Examples:
For 3x+5y+13z~~7, a best solution is x=2,y=z=0x=y=1 and z=05x+11y+16z~~29, the best solution is x=6,y=z=05x+11y+16z=305x+11y+16z=27x=0 and y=z=1 O(D)(or better).
Hint: Suppose a<=b<=c, in what the range around D can the optimal value lie?
Format:
1.Clearly state what the subproblems are. The best way to do it is by writing what OP T() stands for.
2. Explicitly write the recursive formula used to compute OP T() and write its proof of correct-ness.
3. Write the DP algorithm to compute the optimal value. Analyze its running time. (No additional proof of correctness is needed.)
4. Write the backtracking algorithm to identify the set with the optimal value. Analyze its running time.

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!