Skip to content

Instantly share code, notes, and snippets.

@Ray1988
Created March 8, 2013 16:14
Show Gist options
  • Save Ray1988/5117584 to your computer and use it in GitHub Desktop.
Save Ray1988/5117584 to your computer and use it in GitHub Desktop.
TreeNode createminiBST(int arr[], int left, int righ){
if(left> right) return null;
int mid= (left+right)/2;
TreeNode r=new TreeNode(arr[mid]);
r.left=createminiBST(arr, left, mid-1);
r.right=createminiBST(arr,mid, righ);
return r;
}
void creatBST(int[] arr){
creatminiBST(arr, 0, arr.length-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment