I have 2 binary trees, and the value of nodes are not necessary distinct. I want to determine if one tree is a subtree of another.
Is comparing the strings of the pre-order traversal of 2 trees with null nodes sufficient and necessary (iff condition) to determine if a tree is a subtree of another?
For example,
A.left = B
Pre-order: A, B, null, null, null
A.right = B
Pre-order: A, null, B, null, null