Given a binary tree you need to check if the left sub-tree from the root is a mirror image of the right sub-tree.
Please note that the symmetric nature is evaluated purely based on the structure of the tree and not based on any node values.
For example.
1
2 3
4 5
Is a symmetric binary tree.
Where as
1
2 3
4 5
is not a symmetric binary tree.
Your Answer.java should implement the following interface.
public interface SymmetricBinaryTree {
boolean IsBinaryTreeSymmetricAtRoot(Node node);
}
Here is the Node.java. You don't need to upload this file.
public class Node {
public int nodeValue;
public Node lChild;
public Node rChild;
}
Answer
Answer
No comments:
Post a Comment