Home > database >  For help, the last few hours
For help, the last few hours

Time:10-08

#include
#include
#include
Typedef char ElemType;
Typedef struct BiTNode {
ElemType data;
Struct lchild BiTNode * and * rchild;
}
BiTNode, * BiTree;
The Status CreateBiTree (BiTree & amp; T) {
ElemType data;
The scanf (" % c ", & amp; The data);
If (=='^' data) T=NULL;
The else {
if(! (T=(BiTree) malloc (sizeof (BiTNode)))) exit (OVERFLOW);
T - & gt; data=https://bbs.csdn.net/topics/data;
CreateBiTree (T - & gt; Lchild);
CreateBiTree (T - & gt; Rchild);
}
Return ok; }
The Status PreOderTraverse (BiTree T, Status (* Visit) (ElemType e)) {
If (T)
{if (Visit (T - & gt; Data) if (PreOderTraverse (T - & gt; Lchild, Visit) if (PreOderTraverse (T - & gt; Rchild, Visit)
Return ok;
Return the error;
} the else return ok; }
The Status InOderTraverse (BiTree T, Status (* Visit) (ElemType e)) {
If (T) {
If (Visit (T - & gt; Data))
If (InOderTraverse (T - & gt; Lchild, Visit)
If (Visit (T - & gt; Data) if (InOderTraverse (T - & gt; Rchild, Visit)
Return ok;
Return the error;
} the else return ok;
}
The Status PostOderTraverse (BiTree T, Status (* Visit) (TElemType e)) {if (T) {if (PostOderTraverse (T - & gt; Lchild, Visit) if (PostOderTraverse (T - & gt; Rchild, Visit the if (Visit) (T - & gt; Data))
Return ok;
Return the error;
} the else return ok;
} int main ()
{void Test (BiTree & amp; T)
{CreateBiTree (& amp; T);
Printf (" PreOrderTraverse is: "); PreOrder (T, PrintElement);
Printf (" \ n ");
Printf (" InOrderTraverse is: ");
InOrder (T, PrintElement);
Printf (" \ n ");
Printf (" PostOrderTraverse is: "); PostOrder (T, PrintElement));
Printf (" \ n ");
} return ok;
}

CodePudding user response:

So what is the problem?

CodePudding user response:

I think: the second sequence traversal is supposed to be like this:
The Status InOderTraverse (BiTree T, Status (* Visit) (ElemType e)) {
If (T) {
If (InOderTraverse (T - & gt; Lchild, Visit)
If (Visit (T - & gt; Data))
If (Visit (T - & gt; Data) if (InOderTraverse (T - & gt; Rchild, Visit)
Return ok;
Return the error;
} the else return ok;
}

CodePudding user response:

reference 1st floor SuperDay response:
so what is the problem?

Header file indicates a fault, malloc, there??????????????

CodePudding user response:

refer to the second floor zhouzheng11111 response:
I think: the second sequence traversal is supposed to be like this:
The Status InOderTraverse (BiTree T, Status (* Visit) (ElemType e)) {
If (T) {
If (InOderTraverse (T - & gt; Lchild, Visit)
If (Visit (T - & gt; Data))
If (Visit (T - & gt; Data) if (InOderTraverse (T - & gt; Rchild, Visit)
Return ok;
Return the error;
} the else return ok;
}

Ok, thank you oh, I go back to run down

CodePudding user response:

reference qq_45738688 reply: 3/f
Quote: refer to 1st floor SuperDay response:
so what is the problem?

Header file indicates a fault, malloc, there?????

You should be C language, a header file to add. H

CodePudding user response:

reference 5 floor SuperDay reply:
Quote: refer to the third floor qq_45738688 response:
Quote: refer to 1st floor SuperDay response:
so what is the problem?

Header file indicates a fault, malloc, there?????

You, this should be a C header file to add. H

Added. H article wrong number again for a few more, I think it should be me where there is wrong,
Have to look at
  • Related