Empresa engajada
Find whether a given binary tree is image of the other one
Sigiloso
Hope you meant "image" => "clone/replica". Not "Mirror". Here is my take (below code will compare whether two BT are same): // This function will return true if both binary trees are same. Else return false. boolean compare (Node root1, Node root2) { if(root1 == root2) return true; // both are null or both points to same reference, then return true. if( (root1 == null && root2 != null) || (root1 != null && root2 == null) || root1.data != root2.data) return false; // One of them is partial. return compare(root1.left, root2.left) && compare(root1.right, root2.right); }