could u please explain the code with short e.g, i am confused
my code is correct :–
https://ide.geeksforgeeks.org/wD72gm7pD9
suppose a tree is
root is 1
1 has left as 2
1 has right as 3
3 has left as 4
3 has right as 5
rest all are null
now once we traverse whole left we reach 4 where condition fails ,we again go to 3 and conditions fails
than at 3 ,we swap 4 and 5 ?
and also when 2 and 3 are swapped,how now 2 has 5 and 4 as left and right ?
Mirror tree(binary tree)
Hi Shubham, consider the following image:
This is the tree according to your question. The tree on the right is its mirror image. If 4 and 5 were the children of 3, they will not become the children of 2. 2 will still not have any children.