我找到了使用有序和预订遍历(http://www.geeksforgeeks.org/construct-tree-from-given-inorder-and-preorder-traversal/)创建二叉树的实现,除了以下内容我理解了所有内容:
// What does inStrt being greater than inEnd mean?
if (inStrt > inEnd)
return null;
// Why does inStrt == inEnd mean having no children?
if (inStrt == inEnd)
return tNode;
// Why is it that the first call has inIndex - 1 for inEnd, while for the second, inIndex + 1 for inStart?
tNode.left = buildTree(in, pre, inStrt, inIndex - 1);
tNode.right = buildTree(in, pre, inIndex + 1, inEnd);
谢谢你,一定会接受答案