title: Adding a node to a complete tree
body: <p>I'm trying to make complete tree from scratch in C++:</p>
  <pre><code>1st node = root
  2nd node = root-&gt;left
  3rd node = root-&gt;right
  4th node = root-&gt;left-&gt;left
  5th node = root-&gt;left-&gt;right
  6th node = root-&gt;right-&gt;left
  7th node = root-&gt;right-&gt;right
  </code></pre>
  <p>where the tree would look something like this:</p>
  <pre><code>                 NODE
                /        \
            NODE          NODE
         /        \    /        \
      NODE      NODE  NODE      NODE
      /
  NEXT NODE HERE
  </code></pre>
  <p>How would I go about detecting where the next node would go so that I can just use one function to add new nodes? For instance, the 8th node would be placed at <code>root-&gt;left-&gt;left-&gt;left</code></p>
  <p>The goal is to fit 100 nodes into the tree with a simple <code>for</code> loop with <code>insert(Node *newnode)</code> in it rather than doing one at a time. It would turn into something ugly like:</p>
  <pre><code>100th node = root-&gt;right-&gt;left-&gt;left-&gt;right-&gt;left-&gt;left
  </code></pre>