Pocket Gems interview question

Given a preorder traversal construct a valid binary search tree.