title: Algorithm to generate k-combinations of elements of set with repetition?
body: <p>I am looking for an algorithm which takes as input a set of two elements <code>T = {0, 1}</code> and <code>k</code> and generates all <code>k</code>-combinations of <code>T</code> as follows:</p>
  
  <pre><code>000
  001
  010
  011
  100
  101
  110
  111
  </code></pre>
  
  <p>It is straightforward to implement iteratively when <code>k</code> is small, like <code>k=3</code> in the above example. Any ideas how to design a recursive algorithm so that algorithm is independent of <code>k</code>.</p>