title: Pre-Order traversal of binary tree without peramaters
body: <p>This function gets called by the tree object (root) itself. I need to use recursion to display the pre-order traversal. However, the method I have tried is not working because the roots on the stack get updated on every call for every stack frame.</p>
  <p>Here is the main function:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &quot;Tree.h&quot;
  using namespace std;
  
  int main() {
  
      binaryTree* MyTree = new binaryTree();
  
      MyTree-&gt;insert(100);
      MyTree-&gt;insert(25);
      MyTree-&gt;insert(11);
      MyTree-&gt;insert(2);
      MyTree-&gt;insert(87);
      MyTree-&gt;insert(50);
      MyTree-&gt;insert(35);
  
      node* tmp = MyTree-&gt;search(11);
      cout &lt;&lt; &quot;Found &quot; &lt;&lt; tmp-&gt;value &lt;&lt; &quot; located at &quot; &lt;&lt; (int)tmp &lt;&lt; endl;
  
      MyTree-&gt;Display_preorder();
      MyTree-&gt;Display_inorder();
      MyTree-&gt;Display_postorder();
  
      delete MyTree;
  
      return 1;
  }
  </code></pre>
  <p>And here is the Pre-Order Traversal function in the Tree class:</p>
  <pre><code>void binaryTree::Display_preorder()
  {
      if (root == NULL) 
          return;
      
      std::cout &lt;&lt; root-&gt;value &lt;&lt; &quot;, &quot;;
  
      if (root-&gt;left != nullptr) {
          root = root-&gt;left;
          Display_preorder();
      }
  
      if (root-&gt;right != nullptr) {
          std::cout &lt;&lt; root-&gt;value &lt;&lt; &quot;, &quot;;
          root = root-&gt;right;
          Display_preorder();
      }    
  }
  </code></pre>
  <p><strong>The output of the current implemented Pre-Order Traversal:</strong></p>
  <p>100, 25, 11, 2, 2</p>
  <p><strong>Expected output:</strong></p>
  <p>100, 25, 11, 2, 87, 50, 35</p>