This question has already been asked here: http://stackoverflow.com/questions/14092710/equality-of-two-binary-search-trees-constructed-from-unordered-arrays
.
However, the solution that I thought of is fairly simple but hasn't been mentioned there.
The problem statement is: Given two arrays which represent a sequence of keys. Imagine we make a Binary Search Tree (BST) from each array. We need to tell whether two BSTs will be identical or not without actually constructing the tree.
Something that I thought of is, just sort the two arrays. If they are identical, then their inorder traversal will also be identical and hence if the two arrays are identical, then they definitely will lead to the same BST. Am I wrong in assuming that if the inorder traversal of two binary search trees is same, then trees will be same too?