Logic: since n numbers are there,so there can be (2^n)-1 cases.Just as for n bits we have 2^n possible combinations. Keeping above logic in mind,We can also create a binary tree with root node as 0.From there create 2 child nodes:1)number 2) 0. 1st child node indicates that number was taken in subset and 2nd child node indicates that number was not taken.similarly make a tree with all such possible combinations. FInd sum corresponding to all the the paths. If that sum =k(given) then it means subset exists.Else not. Ashima M.Sc.(Tech)Information Systems 4th year BITS Pilani Rajasthan
On Fri, Sep 2, 2011 at 5:26 AM, manish kapur <[email protected]>wrote: > @bharatkumar..cn u pls share the algo > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
