Home > Back-end >  Dizzy dead, hurry by a C implementation of recursive binary tree class
Dizzy dead, hurry by a C implementation of recursive binary tree class

Time:10-07

Through a c + + implementation of recursive binary tree class

CodePudding user response:

#include
#include
using namespace std;
Struct BiTreeNode
{
Char data;
Struct rchild BiTreeNode * and * lchild;
};

The class BiTree
{
Public:
Void the Create (struct BiTreeNode *);
void Display();
};

Void BiTree: : Create (struct BiTreeNode * Tnode)
{
char ch;
Cin> Ch;
If (ch==' ')//space said empty tree
{
Tnode=NULL;
}
The else
{
Tnode=(struct BiTreeNode *) malloc (sizeof (struct BiTreeNode));
Tnode - & gt; data=https://bbs.csdn.net/topics/ch;
Create (Tnode - & gt; Lchild);
Create (Tnode - & gt; Rchild);
}
cout<" The Create Complated!" & lt; & lt; Endl;
}

Int main ()
{

Struct BiTreeNode * Tnode;
BiTree BT1;
BT1. Create (Tnode);
return 0;
}
  • Related