title: Algorithm to Generate 'n' Binary Prefix Codes
body: <p>A <a href="http://en.wikipedia.org/wiki/Prefix_code">Prefix Code</a> is a set of codes such that no code is a prefix of another code.  For example, the following set is a prefix code:</p>
  
  <pre><code>10
  11
  000
  001
  0100
  0101
  0110
  0111
  </code></pre>
  
  <p>With <code>n = 8</code> members.  I think these are usually created with some type of Huffman tree.</p>
  
  <p>My question is: Could you help me create a function that will generate a binary prefix code with 'n' members?</p>
  
  <p>Something like this:</p>
  
  <p><code>list&lt;int&gt; GenerateBinaryPrefixCodes(int n);</code></p>
  
  <p>Also, the requirement is that it be "optimal" in the sense that the total sum of bits is minimized.</p>
  
  <p>I would prefer an answer in C/C++/C#/something similar.  This isn't really homework, but I tagged it that way because it sounds like it would be a good hw problem.</p>
  
  <p>Thanks!</p>