The first traversal in pre-order must be the root of the tree, then K is the root; Then the two sides of K in the middle-order traversal are the left subtree and the right subtree respectively; The left subtree
Node*root=buildTree(seq,index,INT_MIN,INT_MAX); /* 2. Just check if the whole sequence is traversed or not */ returnindex==seq.size(); } intmain() { vector<int>seq={15,10,8,12,20,16,25}; if(isBST(seq)){ cout<<"Sequence represents preorder traversal of a BST"; ...