code for generating BST completed