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 Ist(0), Ist[1], . ,lstfn - 1]. StII, , Istn -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)base case for minStraws(i,T) when T<0:we have to write base case for recurrence function to stop the function.Here straw length won\'t be negative.so,whenever T<0 we consider minimum number of straws required to T when T<0 is 0
so,my answer for this questions is zero(0)
2)base case for minStraws(i,T) when T>0,i=0
This is not a base case :it will covered by the recurrence.becaused we considering sub list 0 to i-1,so,considering 0 in recurrence but i-1 comes under base case at that time we consider as 0
3)base case for minStraws(i,T) when T=0,here T=0 so,my answer for this question is zero(0)
4)??1:1,??2:lst[i-1],??3:0
