|
-
July 24th, 2009, 01:45 PM
#1
generate subsets
I'd like to generate all subsets of a given set recursively.
For example ,
A = { 1, 2, 3 }
The subsets will be {}, { 1 }, { 2 }, { 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 }, { 1, 2, 3 }
I'm having trouble coming up with a recursive way to do this.
Could someone help me out in this please ?
Thanks..
-
July 24th, 2009, 02:56 PM
#2
Re: generate subsets
I'm not sure how to do it recursively. The easy way to do it is to count from 0 to 2^3-1, and use the bits to indicate membership.
-
July 25th, 2009, 08:35 AM
#3
Re: generate subsets
I am aware of that technique. I heard that there was a recursive way of doing it and was wondering how to do it.
-
July 26th, 2009, 05:27 AM
#4
Re: generate subsets
Google is your friend.
Tons of links with examples & implementations.
Regards,
Zachm
-
July 27th, 2009, 05:36 AM
#5
Re: generate subsets
Thanks...
I did search on google but I guess I chose the wrong search terms.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|