sorted Array to BST
struct BinaryTree{
int value;
struct BinaryTree* left;
struct BinaryTree* right;
BinaryTree(int val){this->value=val;}
};
BinaryTree* sortedArrayToBST(int arr[],int start,int end){
if (start>end) {
return NULL;
}
int mid=start+(end-start)/2;
BinaryTree* node=new BinaryTree(arr[mid]);
node->left=sortedArrayToBST(arr, start, mid-1);
node->right=sortedArrayToBST(arr, mid+1, end);
return node;
}
BinaryTree* sortedArrayToBST(int arr[],int n){
return sortedArrayToBST(arr, 0, n-1);
}