Home > Back-end >  Small white consult!!!!! Questions about the establishment of a binary tree (the Run - Time Check Fa
Small white consult!!!!! Questions about the establishment of a binary tree (the Run - Time Check Fa

Time:02-15

I'm trying to set up the binary tree:
//triggered the untreated exception: read access rights conflict, the tree is 0 xfffffff8,
//the Run - Time Check Failure # 2 - Stack around the variable 'tre)
Errors, such as online query many said the problem for the pointer, but I still can't find the problem of the source, bosses, please advise!
Below is my
#include
# include

The structure of the tree//
Typedef struct ThreadNode {
Char data;
Int ltag rtag;//tag is equal to 1 indicates clues
Struct lchild ThreadNode * and * rchild;
} ThreadNode, * ThreadTree;

//clues
Void initTag (ThreadNode * node)
{
Node - & gt; Ltag=node - & gt; Rtag=0;
}

The pre ThreadNode *=NULL;

//clues to the establishment of a binary tree
ThreadTree creatTree ()
{
ThreadTree tree;
Char STR.
STR=getchar ();
If (STR=='#')
The tree=NULL;
The else {
The tree=(ThreadNode *) malloc (sizeof (ThreadNode));
InitTag (& amp; A tree);
The tree - & gt; Data=https://bbs.csdn.net/topics/str;
The tree - & gt; Lchild=creatTree ();
The tree - & gt; Rchild=creatTree ();
}
Return the tree;
}

///sequence traversal clues in the binary tree
Void visit (ThreadNode * node)
{
If ((* node). Lchild==NULL)
{
(* node). Lchild=pre;
(* node). Ltag=1;
}
If (pre!=NULL & amp; & The pre - & gt; Rchild==NULL)
{
The pre - & gt; Rchild=node;
The pre - & gt; Rtag=1;
}
The pre=node;
}

Int main ()
{
ThreadTree tree=creatTree ();
InThread (& amp; A tree);

return 0;
}
Input: ABC# D# # # #

CodePudding user response:

Understand is my clues on tree node is initialized, travels is a primary address pointer, the function of receiving is also a primary pointer go wrong!
  • Related