Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please provide code that works for the following problems 1) You are given n typ

ID: 3689080 • Letter: P

Question

Please provide code that works for the following problems

1) You are given n types of coin denominations of values v(1) < v(2) < ... < v(n) (all integers). Assume v(1) = 1, so you can always make change for any amount of money C. Give an algorithm which makes change for an amount of money C with as few coins as possible.

2) This is the same problem as the example above, except here it is forbidden to use more than one instance of each type of item.

3) You have a set of n integers each in the range 0 ... K. Partition these integers into two subsets such that you minimize |S1 - S2|, where S1 and S2 denote the sums of the elements in each of the two subsets.

Explanation / Answer

1) You are given n types of coin denominations of values v(1) < v(2) < ... < v(n) (all integers). Assume v(1) = 1, so you can always make change for any amount of money C. Give an algorithm which makes change for an amount of money C with as few coins as possible.

Step 1: Start

Step 2: Create a Procedure/function coinDenomination for Calculation

Step 3: Read the denomination value 'n'

Step 4: if check v(n) here v is the describes the value of n

Step 5: if v(n) == 1 then

            Display value of denomination is 1

Step 6: check values like v(2),v(3)......v(n)

Step 7: c is the change value of money

Step 7: if v(1) < v(2)

            changes the value of c

            do this simillar to up to v(n)

            change the values of c

Step 8: Stop

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote