I know the iterative solution:
given a set of n elements
save an int v = 2^n and generate all binaries number up to this v.
But what if n > 32?
I know it’s already 2^32 subsets, but yet – what’s the way to bypass the 32 elements limitation?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re happy with a 64 item limit, you can simply use
long.Array /
ArrayListofints /longs. Have anextfunction something like:BitArray. Probably not a very efficient option compared to the above.
You can have a
nextfunction which sets the least significant bit 0 to 1 and all remaining bits to 0. e.g.:Note – this will probably take forever, simply because there’s so many subsets, but that’s not the question.