Results 1 to 6 of 6
- 04-20-2011, 02:06 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 11
- Rep Power
- 0
-
If S is the set {x, y, z}, then the subsets of S are:
{} (also denoted , the empty set)
{x}
{y}
{z}
{x, y}
{x, z}
{y, z}
{x, y, z}
Is this what you are trying to do?
- 04-20-2011, 02:16 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 11
- Rep Power
- 0
Yup!
Basically, but all in one string:
["", a, b, ab, ba, abab, baba]Last edited by csisdifficult; 04-22-2011 at 02:51 PM.
- 04-20-2011, 02:34 AM #4
Member
- Join Date
- Apr 2011
- Posts
- 11
- Rep Power
- 0
Please? Someone help?
-
In one List, of course.
Something to start you off:
Java Code://define a List because you don't know how many items you need to store in it List<String> powerSet = new ArrayList<>(); //define set to make powerSet from char[] aSet = new char[] {'a', 'b', 'c'}; //loop through each character //define a String to store full set String fullSet = ""; //add blank to List powerSet.add(fullSet); for (int i=0; i<aSet.length; i++) { //add each item in set powerSet.add(aSet[i]); //compile the full set fullSet += aSet[i]; } //add full set powerSet.add(fullSet);
So far this would get us everything except the 'ab', 'ac' and 'bc'.
ab, ac, bc... is like this: aa, ab, ac, ba, bb, bc, ca, cb, cc
but with same letter combos removed (aa, bb, cc)
and doubles removed (ab = ba, ac = ca, bc = cb)
- 04-20-2011, 02:45 AM #6
Member
- Join Date
- Apr 2011
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
very frustrating.. recursive
By Yakg in forum New To JavaReplies: 5Last Post: 01-06-2011, 10:25 PM -
recursive function
By jayden in forum New To JavaReplies: 11Last Post: 09-02-2010, 03:00 PM -
recursive method
By michail in forum New To JavaReplies: 0Last Post: 01-31-2010, 01:50 PM -
basic help with Recursive
By syntrax in forum New To JavaReplies: 3Last Post: 12-15-2009, 06:19 AM -
Help with recursive implementation
By toby in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:57 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks