Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make subset or powerSet quickly and efficiently in java from a list?
    primarykey
    data
    text
    <p>I'm going through a problem of making subsets or powersets from an arrayList with may be 70 or 80 or more String elements and then further process those subsets(or powersets). For example I have some arrayLists which have non duplicate strings as element like the following (strings actually have more than one characters):</p> <pre><code>List&lt;String&gt; list = new ArrayList&lt;&gt;(); list.add("a"); list.add("c"); list.add("g"); list.add("n"); list.add("f"); and so on... </code></pre> <p>Then I need to get the subsets(or powersets) contains the 1st element. for example:<code>{a,g}, {a,b}, {a,n,f}, {a,g,n,f}....</code></p> <p>I've done the job by getting the powersets for the list elements except the first one and then adding the fist element with those subsets. But this works for few elements like 7 or 8 but could not work if the list grows. Is it required to do a powerSet algorithm like I'm doing for this job? If not then how can I get the expected results. And there have been a matter of memory-leak I think. As I need to store those results for some further processing.</p> <p>I've done the job by following some of the suggestions regarding to the following links:</p> <p><a href="https://stackoverflow.com/questions/1670862/obtaining-powerset-of-a-set-in-java">Obtaining a powerset of a set in Java</a> <br/> <a href="https://stackoverflow.com/questions/4640034/calculating-all-of-the-subsets-of-a-set-of-numbers">Calculating all of the subsets of a set of numbers</a> <br/> <a href="https://stackoverflow.com/questions/11021594/how-to-make-all-possible-power-setor-subset-from-arraylist-objects">how to make all possible power set(or subset) from arrayList objects?</a> <br/></p> <p>But those takes many hours for large list and could not get results at last because my netbeans IDE get hanged! </p> <p>I need some suggestions or sample code related to this scenario.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload