how to rebuild BST using {pre,in,post}order traversals results
问题 We know the pre-order, in-order and post-order traversals. What algorithm will reconstruct the BST? 回答1: Because it is BST, in-order can be sorted from pre-order or post-order <1>. Actually, either pre-order or post-order is needed only.... <1> if you know what the comparison function is From pre-order and in-order , to construct a binary tree BT createBT(int* preOrder, int* inOrder, int len) { int i; BT tree; if(len <= 0) return NULL; tree = new BTNode; t->data = *preOrder; for(i = 0; i <