This is a general method for tackling and resolving this issue. The following example is written in Python. # Python function for creating a binary tree from two traversal sequences. class Node : def __init__ ( self , data ) : self . data = data self . left = None self . right = None def buildTree ( inOrder , preOrder , inStrt , inEnd ) : if ( inStrt > inEnd ) : return None # Select the current node from the Preorder sequence with preIndex and increase preIndex tNode = Node ( preOrder [ buildTree . preIndex ] ) buildTree . preIndex += 1 # If this node has no children, return it if inStrt == inEnd : return tNode # Otherwise, find the index of this node in the Inorder sequence inIndex = search ( inOrder , inStrt , inEnd , tNode . data ) # Using the index from the Inorder sequence, build the left and right subtrees tNode . left = buildTree ( inOrder , preOrder , inStrt , inIndex - 1 ) tNode . right = buildTree ( inOrder , preOrder , inIndex + 1 , inEnd ) return tNode # Function to find and return the index def search ( arr , strt , end , value ) : for i in range ( strt , end + 1 ) : if arr [ i ] == value : return i buildTree . preIndex = 0