Originally Posted by
cfan
i have an inorder traversal array (in every node we have only two sons or no sons)
and i need to construct a BST tree out of it.
if i had freedom i would do a fuction of node build(arr,start,end)
ABCREFG
i would build a recursive function which will get R in the middle
then for the leftside i would send indexes from A to C
and for the right side E to G
but i am asked to write a function which has only node * build(int* arr,lenght);
how??
You can convert between the two. When you want to write:
Code:
build( arr, start, end );
Instead you write:
Code:
build( arr + start, end - start );