check route and create minimal height bst with sorted array