Question: Question 2 : Bad sizes 2 ( C ) Recover the solution in terms of the growth from each drop of fertilizer. [ 1 6

Question 2: Bad sizes 2(C) Recover the solution in terms of the growth from each drop of fertilizer. [16]: ## Test Code: Do not edit
print(minGoodDrops_Solution(9)) # should be 2,[4,4]
print(minGoodDrops_Solution(13)) # should be 2,[11,1]
print(minGoodDrops_Solution(19)) # should be 4,[4,5,4,5]
print(minGoodDrops_Solution(34)) # should be 5,[5,1,11,11,5]
print(minGoodDrops_Solution(43)) # should be 5,[4,5,11,11,11]
print(minGoodDrops_Solution(55)) # should be 6,[5,11,11,11,11,5]
print(minGoodDrops_Solution(69)) # should be 8,[11,1,11,11,11,11,11,1]
inf
1
Mr E has noticed something quite strange: Any bean stalk whose length leaves a remainder of 2 when divided by 7 dies over night.
He demands you change your algorithm to avoid these 'dead lengths.' You think it might just be his cat digging around in the pots late at night, but you don't wish to argue.
2(A) Write a recurrence.
Write a recurrence minGoodDrops (j,n) that represents the minimum number of drops of fertilizer necessary to grow a bean stalk from j inches to n inches, avoiding any intermediate stage of length k when k mod 7=2.
*[1]: def minGoodDrops(j, n):print(minGoodDrops(1,9)) # should be 2
print(minGoodDrops(1,13)) # should be 2
print(minGoodDrops(1,19)) # should be 4
print(minGoodDrops(1,34)) # should be 5
print(minGoodDrops(1,43)) # should be 5
print(minGoodDrops(1,55)) # should be 6
inf
1
1
12(B) Memoize the recurrence in 2(A)
[10]: def minGoodDrops_Memoize(n): # j is assumed to be 1
return 100print(minGoodDrops_Memoize(9)) # should be 2
print(minGoodDrops_Memoize(13)) # should be 2
print(minGoodDrops_Memoize(19)) # should be 4
print(minGoodDrops_Memoize(34)) # should be 5
print(minGoodDrops_Memoize(43)) # should be 5
print(minGoodDrops_Memoize(55)) # should be 6
print(minGoodDrops_Memoize(69)) # should be 8
print(minGoodDrops_Memoize(812)) # should be 83
100
100
100
 Question 2: Bad sizes 2(C) Recover the solution in terms of

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!