## Oracle Interview Question

Software Engineer / Developers**Interview Type:**In-Person

```
public static TNode createTree2(int array[], int start, int end, TNode root){
if(start < 0 || end >= array.length || start > end){
return root;
}else{
int middle = ((end - start)/2)+start; // middle Index
root =insert(root,array[middle]);
createTree2(array,start,middle-1,root);
createTree2(array,middle+1,end,root);
}
return root;
}
```

.

- saumya.tyagi6 January 22, 20141. Recursively calculate mid

2. Make it root node.

3. Nd keep doing this process for other two halves of array

T(n)=2T(n/2)+1

it will give us o(n) time complexity

space complexity-o(n) for recursive stack