I am very confused by a number of articles on different sites regarding the construction of a Binary Search Tree from any crawl ( pre , post or in-order ) or a combination of any two of them. For example, the this page says that bypassing the pre , post or level in-order , as well as in-order bypass, you can build a BST . But here and there , they show us the BST design from pre-order . They also show us here how to build a BST from pre and post-order workarounds. In another place, I found a solution to build BST only from the post-order bypass.
Now I know that inorder and pre-order you can uniquely form a BST . Regarding the first link I provided, although they say that we cannot build BST from pre-order and post-order , can I just sort the post-order array to get its inorder bypass and then use this and the array pre-order to form a BST ? Will it be the same as the decision in the 4th link, or another? And just for pre-order , I can sort this to get in-order , and then use it and pre-order to get BST . Again, should this be different from the solution in links 2 and 3?
In particular, what is enough to uniquely generate a BST ? If uniqueness is not required, then I can simply sort it to get an in-order bypass, and build one of N possible BST from it recursively.
algorithm binary-search-tree preorder inorder postorder
SexyBeast
source share