The order required to print the output is not clear here where it is preorder or inorder or postorder.
What is the order of the display function?
The printing is done as per the preorder traversal only, but you need to include various different conditions as well like, for the cases as,
if(root->left!=NULL && root->right==NULL)
if(root->left ==NULL && root->right==NULL)
if(root->left==NULL && root->right!=NULL)
if(root->left!=NULL && root->right!=NULL)
Under these conditions, there is a difference in printing, pls first build tree and then try to implement this function, you will understand it better…
Since you arent responding, I am marking this as resolved , You can reopen it again, if you face any doubt…