Regarding tree traversal : <p>Tried code for tree traversal but I'm not getting the expected output.</p>

<pre><code>tree* insertion(int data)
{
 tree *ptr=new tree();
 ptr-&gt;data=data;
 ptr-&gt;left=NULL;
 ptr-&gt;right=NULL;
}
void preorder(tree* root)
{
if(root==NULL)
    return;
cout&lt;&lt;root-&gt;data&lt;&lt;" ";
preorder(root-&gt;left);
preorder(root-&gt;right);
}
void postorder(tree* root)
{
if(root==NULL)
    return;
preorder(root-&gt;left);
preorder(root-&gt;right);
cout&lt;&lt;root-&gt;data&lt;&lt;" ";
}
void inorder(tree* root)
{
if(root==NULL)
    return;
preorder(root-&gt;left);
cout&lt;&lt;root-&gt;data&lt;&lt;" ";
preorder(root-&gt;right);
}
</code></pre>

<p>expected output: (a) Inorder (Left, Root, Right) : 4 2 5 1 3
(b) Preorder (Root, Left, Right) : 1 2 4 5 3
(c) Postorder (Left, Right, Root) : 4 5 2 3 1</p>

<p>My output: Preorder traversal : 1 2 4 5 3
Postorder traversal : 2 4 5 3 1
Inorder traversal : 2 4 5 1 3</p>
