给定二叉树的数据类型如下
typedef char Element;
struct Node
{
Element data;
struct Node *lchild;
struct Node *rchild;
};
typedef struct Node BTNode;
typedef struct Node * BTree;
二叉树创建I
完成BTree Create_BTree(char s[])函数,该函数由字符串s创建一颗二叉树,其中字符串s是仅由’(‘,’)’,’,’以及大小写字符构成的二叉树的广义表表示,如A(B(D,),C(E,F(,H))),字符串s以’\0’结尾。
BTree NewNode(Element x)
{
BTree p=(BTree)malloc(sizeof(BTNode));
p‐>data=x;
p‐>lchild=NULL;
p‐>rchild=NULL;
return p;
}
BTree Create_BTree(char s[])
{
int i,k,top;
BTree path[N],p;
k=0;
top=‐1;
for(i=0;s[i]!='\0';i++)
{
switch(s[i])
{
case