We have a bunch of straws of various lengths which need to b

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 T

Solution

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

 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 f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site