phoenix
BAN USER
Questions (2)
Comments (2)
Reputation 240
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I agree with you. we cannot determine a tree structure unique only using inorder. we need to combine pre-order/ post-order with in-order to produce a unique tree.
In order to solve the problem we need to store inorder sequence in a array and then preorder/postorder in one more array. Then compare both these arrays against second tree.
time complexity would be O(n).
but space complexity would be O(2n).
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Can you explain the logic?
- phoenix August 21, 2014