递归实现:
数组中间节点做为根节点, 然后把左边的数组递归赋予左子树,右边数组递归赋予右子树
struct TreeNode* sortedArrayToBST(int* nums, int numsSize) {
if(nums == NULL || numsSize == 0)
return NULL;
int mid = (numsSize-1)/2;
int val = nums[mid];
struct TreeNode * node = calloc(1, sizeof(struct TreeNode));
node->val = val;
node->right = sortedArrayToBST(nums+mid+1,numsSize-mid-1);
node->left = sortedArrayToBST(nums,mid);
return node;
}