How do you find if onetree is subset of the other
Software QA/Tests Interview Questions from Microsoft
(Continued from previous question...)
How do you find if onetree is subset of the other
Question:
How do you find if onetree is subset of the other
maybe an answer:
in any case,
Method 1 : memory inefficient, time + code efficient.
1. take the inorder traversal of both the trees.
2. find the longest subsequence in the two arrays.
3. if one of the array is entirely the longest subsequence, you got it, else not.
Method 2: memory efficient, time inefficient.
1. search for the root of one tree in the other.
2. if found try to match the structure, from there, using inorder as well as preorder traversal.
(Continued on next question...)
Other Interview Questions
