So basically I need to write a function that mirrors a binary tree. [Mirror trees example1
My approach : visit all nodes once and swap left and right children. To traverse we can use any of the three traversals. When I am using preorder and postorder, I am getting the desired result but not with inorder!
void asd(struct node* root)
{if(root == NULL)
return;
asd(root->leftChild);
struct node* t;
t=root->leftChild;
root->leftChild= root->rightChild;
root->rightChild =t;
asd(root->rightChild);
}
My function for mirroring with inorder traversal. I am not able to understand why?