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

You work on your thesis over the weekend, and every time you make a change to yo

ID: 3696928 • Letter: Y

Question

You work on your thesis over the weekend, and every time you make a change to your code, you run your test-awesomeness. py script, which spits out a score telling you how awesome your code is. During two hard days of work, you accumulate a large, time-ordered list of these awesomeness scores, e.g., [32, 31, 46, 36, 32, 36, 30, 33, 22, 38, 2, 13]. You have a weekly meeting with your advisor, and each week you have to show that you made progress, so that he'll leave you alone for another week. You devise a plan in which every week you will show your advisor a newer version of your code, along with an awesomeness score that is better than the previous week's. To maximize the number of weeks of slacking you get out of your two days of work, you need to calculate a lingest increasing subsequence of your awesomeness scores. In the example, one such subsequence would be [31, 32, 36, 38]. The subsequence should be strictly increasing, because you need to show improvement each time. Thinking back to your Introduction to Algorithms days, you have a vague recollection that longest increasing subsequence is one of those problems that can be solved by Dynamic Programming. Clearly state the set of subproblems that you will use to solve this problem. Write a recurrence relating the solution of a general subproblem to solutions of smaller subproblems. Analyze the running time of your algorithm, including the number of subproblems and the time spent per subproblem.

Explanation / Answer

def recDC(coinValueList,change,knownResults):
minCoins = change
if change in coinValueList:
knownResults[change] = 1
return 1
elif knownResults[change] > 0:
return knownResults[change]
else:
for i in [c for c in coinValueList if c <= change]:
numCoins = 1 + recDC(coinValueList, change-i,
knownResults)
if numCoins < minCoins:
minCoins = numCoins
knownResults[change] = minCoins
return minCoins

print(recDC([1,5,10,25],63,[0]*64))

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