Question: . Problem Statement Ramya has two children. One day she gave them a jigsaw puzzle and said that if they solved the puzzle together, then

. Problem Statement Ramya has two children. One day she gave them a jigsaw puzzle and said that if they solved the puzzle together, then she will let them take the money from the piggy bank to buy snacks that they like. Children became happy and they spent two hours solving the jigsaw puzzle. As promised Ramya opened the piggy bank and to be fair, she divided the money between the children such a way that the difference between the money that each children got was the minimum. Requirements: 1. Formulate an efficient recursive algorithm using Dynamic programming to divide the money as equal as possible 2. It is possible that there can be more than one way of dividing the money and still keep the difference to the minimum, in which case, display one such combination in the output 3. Also develop a non-recursive, linear-time algorithm for the above problem. 4. Analyze the time complexity for requirement 1. 5. Implement the above problem statement using Python 3.7 Sample Input: Input should be taken in through a file called inputPS08.txt which has the fixed format as mentioned below where the money denomination is split by comma Test case 1: 1, 1, 1, 2, 2, 3, 4, 5, 10, 15, 18 Test case 2: 1, 2, 3, 5, 8, 9, 11, 14, 15, 22, 25 Sample Output: Dynamic programming: Test case 1: First child: 1, 1, 1, 2, 2, 4, 5, 15. Total = 31 Second child: 3, 10, 18. Total = 31 Difference = 0 Test case 2: First child: 1, 3, 8, 9, 14, 22. Total = 58 Second child: 2, 5, 11, 15, 25. Total = 57 Difference = 1

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 Databases Questions!