build bst from sorted array