#dene OVERFLOW -2
typedef int status;
typedef struct BiNode//二叉链表
{
char Data;
struct BiNode* lChild;
struct BiNode* rChild;
}BiNode,*pBiNode;
typedef struct SNode/*链栈的结点类型*/
{
pBiNode elem; /*栈中的元素是指向二叉链表结点的指针*/
struct SNode *next;
}SNode;
struct link //队列链表
{
struct BiNode *p;
struct link *next;
};
status CreateTree(BiNode** pTree);
status PreOrderTraval(BiNode* pTree);//前序递归
status InOrderTraval(BiNode* pTree);//中序递归
status PostOrderTraval(BiNode* pTree);//后序递归
status st_InOrderTraverse(BiNode* pTree);//中序非递归遍历
void TreeLink(BiNode* pTree); //队列实现层次遍历
int TreeHeight (BiNode* pTree);//二叉树的高度
int Count(BiNode* pTree);//结点个数
int TreeNumber(BiNode* pTree);//叶子个数
void Exchange (BiNode* pTree);//交换左右子树
status Visit(char Data);
void Display(BiNode* pTree,int Level);
BiNode *pRoot=NULL;
status CreateTree(BiNode** pTree) /*Input Example: abd##e##cf##g##*/
{
char ch;
scanf("%c",&ch);
if(ch=='#')
{
(*pTree)=NULL;
评论0
最新资源