jjzjj

preIndex

全部标签

java - 用Java重写一段C代码构造满二叉树

我想编写一个函数,根据给定的前序和后序数组构造一棵完整的二叉树。我找到了那个链接http://www.geeksforgeeks.org/full-and-complete-binary-tree-from-given-preorder-and-postorder-traversals/它提出了以下C代码:structnode*constructTreeUtil(intpre[],intpost[],int*preIndex,intl,inth,intsize){//Basecaseif(*preIndex>=size||l>h)returnNULL;//Thefirstnodeinp