We have a bunch of straws of various lengths, which need to be combined to form
ID: 3774208 • Letter: W
Question
We have a bunch of straws of various lengths, which need to be combined to form a long straw of a target length L. The lengths of the straws are given in the form of a list of n elements lst 0], lst[1], lst n -1 The goal is to choose the least number of straws from the list whose lengths add up to the target length L. Let minstraws( i, T)denote a recurrence that selects the minimum number of straws chosen from the sublist lst 0, lstli 1 of the first i elements of the list with a target length T We wish to write a recurrence for minstraws(i, T) Select all the correct choices for the base case for minstraws( i, T) when TExplanation / Answer
1)minStraws(i,T) when T<0?
Ans:This is not a base case:it will be covered by the recuurrence
explanation:length of straws should not be negative.T<0 means length is 0.which is not possible
2)minStraws(i,T) when i=0, T>0?
ans:1 (means we take one value from the list that is lst[0])
3)minStraws(i,T) when T=0?
Ans: 0(because length is zero no need sum any elements from the list)
4)This question is not clear and some data is missing
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.