[SOLVED] CS293 Assignment 2- Distributing Chocolates

39.99 $

Category: Tags: , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment-2-dcz5pw.zip (107.4 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (2 votes)

Sample Input/Output
Input Possible output
12 3 3 5 4 2 1 1 2 2 1 2 0
Hint: If we get all chocolates in one bag, then it is easy to distribute nearly equally. One way of ensuring that a sequence of steps ends up with a given distribution is to define an order relation on the distributions, such that the required distribution is the minimum element. At every step ensure that you move to a distribution that is β€˜smaller’ in the ordering. Since there are only finitely many distributions, you will eventually reach the minimum. Can you think of such a relation for this problem?
Submission: Name the file as RollNo 2.cpp and submit on moodle.
Homework: A more general problem is given arbitrary initial and final distributions of chocolates, find a sequence of steps that leads from the initial to the final. Is this always possible? What can you say about the number of moves required?
1

  • Assignment-2-dcz5pw.zip