Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

What s the acronym to summarize stakeholders roles they play?

Answered: 1 week ago