题目: 数组按照前序遍历方式方式转化为二叉树
思路: 二叉树前序遍历变形
代码:
Node * BinaryInit(int *a, int index, int len)
{
if (index > len - 1)
return NULL;
Node *pNode = (Node *)malloc(sizeof(Node));
pNode->val_ = a[index];
pNode->pLeft = BinaryInit(a, 2*index+1, len);
pNode->pRight = BinaryInit(a, 2*index+2, len);
return pNode;
}