creates a BST from a sorted array