yeah i wen first post answer i said it is for finding sum=k; n just add one more condition in loop for finding <k; i.e. if(sub+a[i]<k) return sub,a[i];
is it fine nw? On Sat, Aug 27, 2011 at 7:55 AM, raj kumar <megamonste...@gmail.com> wrote: > It's not knapsack in knapsack we find max or min subset here we have to > find all subsets <=k not just one which is min or max , so I guess we have > to form all subsets and check their sum hence the algoritm will be 0(2^n) > where n is number of elements in the set , > > se correct me if i am wrong or a better solution exists > > > thanks > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.