build binary search tree with a sorted array