title: Binary Search Tree C++ at Display
body: <p>How do I get the code to say at Insertion:</p>
  
  <ul>
  <li>Root Node is Added (1st insert),</li>
  <li>Node Added to Left (2nd insert),</li>
  <li>Node Added to Right (3rd insert), </li>
  <li>Node Added to Right (4th insert),</li>
  </ul>
  
  <p>right below when each node is added.</p>
  
  <p>There's something wrong with my display. I can't get it to run. Code
  is as below in the link. I need to display the tree structure from the result of all insertion.</p>
  
  <p><a href="http://goo.gl/NXAwrE" rel="nofollow">http://goo.gl/NXAwrE</a></p>
  
  <pre><code>void BinarySearchTree::display(tree_node *ptr, int level)
  {
      int i;
      if (ptr != NULL)
      {
          display(ptr-&gt;right, level+1);
          cout&lt;&lt;endl;
          if (ptr == root)
              cout&lt;&lt;"Root-&gt;:  ";
          else
          {
              for (i = 0;i &lt; level;i++)
                  cout&lt;&lt;"       ";
      }
          cout&lt;&lt;ptr-&gt;data;
          display(ptr-&gt;left, level+1);
      }
  }
  
  case 5:  cout&lt;&lt;"Display BST:"&lt;&lt;endl;
           b.display(tmp,1);
           cout&lt;&lt;endl;
           break;
  </code></pre>