title: Algorithm for calculating the power set
body: <p>I just discovered an algorithm for finding the power set. I googled after solutions, but found none that worked any good, so I figured out one myself. But I wonder what algorithm it is, because I cannot find it on the net or in any books. I mean, does it have a name? Compared to the algorithms I found on some sites for calculating the power set, I think mine is far better and wonder why no one uses it?</p>
  
  <p>This is the algorithm:</p>
  
  <pre><code>R &lt;- []
  L &lt;- [ e1, e2 ... en ]
  c &lt;- 0
  function: powerSet(L, c)
    R &lt;- R union L
    for e in L starting at c
      powerSet(L\{e}, c)
    end
    return R
  end
  </code></pre>
  
  <p>And here it is implemented in Java:</p>
  
  <pre><code>public static void powerSet(List&lt;String&gt; list, int count)
  {
    result.add(list);
  
    for(int i = count; i &lt; list.size(); i++)
    {
      List&lt;String&gt; temp = new ArrayList&lt;String&gt;(list);
      temp.remove(i);
  
      powerSet(temp, i);
    }
  }
  </code></pre>