Suppose we have two array inorder and preorder containing the elements in the said format.

Using these two arrays how can i generate the binary tree??

Any help on the algorithm to be followed will be highly appreciated.

For eg:

inorder is : 2 3 4 5 6 7 8

preorder is : 5 3 2 4 7 6 8

then the Binary tree shld be

**____**5

**____**/\

**_3_7**2_4 6_8

___/_/\

How can i form this binary tree??

i know the algorithm by hand but how do i implement it in C??