title: C++ How to store the nodes of an in order traversal into an array?
body: <p>I have an in-order traversal function like such</p>
  <pre><code>
  void Inorder(node *root)
  {
      node* array;
      array = new node[arraySize];
  
  
      if (root == NULL)
          return;
      Inorder(root-&gt;left); //visit left sub-tree
      
  
      std::cout &lt;&lt; &quot;Word: &quot; &lt;&lt; root-&gt;key &lt;&lt; std::endl
                &lt;&lt; &quot;Occurance: &quot; &lt;&lt; root-&gt;count &lt;&lt; std::endl; //print root key and its count
  
      Inorder(root-&gt;right); //visit right sub-tree
      
  }
  </code></pre>
  <p>In order to sort it any further I need to store the node transversed in an array however im not sure i can accomplish this. Visually i want something like this</p>
  <pre><code>node array[0] = transversedNode; 
  </code></pre>
  <p>Ive tried adding root to the array
  Ive tried adding  Inorder(root-&gt;left) to the array when Inorder is of type node</p>
  <p>But none of these accomplish what i need. Is it possible to store the nodes transversed into an array? Thankyou</p>