#include<stdio.h>
#include<stdlib.h>
#define N 20
typedef struct node //节点创建
{
char data;
struct node *lchild,*rchild;
int index;
}BiTree;
typedef struct tree //静态二叉树结点
{
char data;
int left;
int right;
}treenode;
typedef struct QUEUE
{
BiTree ch;
struct QUEUE *next;
}Queue,*que; //定义队列结点结构
typedef struct
{
que front;
que rear;
}linkqueue;
static int i=0,n=0;
BiTree *CreateTree() //用递归方法创建树
{
BiTree *T;
char ch;
scanf("%c",&ch);
if(ch==' ')
T=NULL;
else
{
T=(BiTree*)malloc(sizeof(BiTree));
T->data=ch;
T->index=i++;
T->lchild=CreateTree(); //递归左子树
T->rchild=CreateTree(); //递归右子树
}
return T;
}
void initqueue(linkqueue &
二叉树的的所有操作——转化为静态二叉链表,求深度,求先序排列,求中序排列,求后序排列,求层次遍历,求度为0.1.2的节点个数
最新推荐文章于 2025-01-18 17:42:21 发布