Coursera's Algorithmic toolbox assignment solutions( Money Change, Maximum Value of the Loot ) :
Problem 1: Money Change
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
This code is simple. There's no need for any explanation.
or
you can also use this code below if denominations are given as input in descending order.
Problem 2: Maximum Value of the Loot
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
Well , the solution is here. What i did here is in accordance with the lecture , we will first see which item has the highest v/w i.e r value and then we will put that item whole in the knapsack if possible , if space is left , we will take the next maximum v/w value and put that item whole in the knapsack if possible. We will repeat this procedure until the knapsack becomes full. This will help us find the optimal solution for our problem.
Guys , if you have any queries related to a question or need more explanation, comment down below!
Suppose if someone copies the code as it is, what are the chances to get caught in plagiarism? And what can be the consequences?
ReplyDeleteI have heard that coursera detects the same code that is submitted by another person. In that case they will end your course. So don't just copy paste. Try to understand the problem and use different variables.
Delete