title: Construct non-binary tree from pre-order traversal
body: <p>Given a list of nodes and the number of children it has, construct a (non-binary) tree from this list (which is in pre-order traversal)</p>
  
  <p>for example I am given the following:</p>
  
  <pre><code>1 3
  2 1
  3 0
  4 0
  5 0
  </code></pre>
  
  <p>which is a tree that looks like</p>
  
  <pre><code>           1
            /|\
           / | \
          2  4  5
         /
        3
  </code></pre>
  
  <p>I know I should use recursion to construct this tree, but because it's not a binary tree, I'm pretty lost as to how this algorithm should be implemented.</p>