📄 st_bt.h
字号:
//St_BT.h
//uuhorse
//2008.05.17
#ifndef _MG_BITREE_VERSION1_
#define _MG_BITREE_VERSION1_
#include <stdio.h>
#include <malloc.h>
typedef char TElemType;
typedef int Status;
typedef struct BiTNode
{
TElemType data;
struct BiTNode *lchild, *rchild;
}BiTNode, *BiTree;
Status InitBiTree (BiTree &T); //构造空二叉树T
Status DestoryBiTree (BiTree &T); //销毁二叉树 T
Status BiTreeEmpty (BiTree &T); //若T为空二叉树,返回true,否则,返回false
int BiTreeDepth (BiTree &T); //返回树T的深度
BiTNode Root (BiTree &T); //返回树T的根节点
BiTNode *FineNode (BiTree T, TElemType e);//查找data域为e的节点
BiTNode *Parent (BiTree T, TElemType e);//返回节点e的双亲
BiTNode *LeftChild (BiTree T, TElemType e);//返回节点e的左孩子
BiTNode* RightChild (BiTree &T, TElemType e);//返回节点e的右孩子
Status InsertChild (BiTree &T, BiTNode* p, Status LR, TElemType c);
//根据LR为0或1,在节点p处插入左孩子节点或右孩子节点,p原有子树成为c的右子树
Status DeleteChild (BiTree &T, BiTNode* p, Status LR );
//根据LR为0或1,删除T中p所指向节点的左孩子或右孩子
Status Visit (BiTNode* p);//对节点进行访问输出
Status Assign (BiTree &T, TElemType &e, TElemType value);//二叉树存在,e是T的某个节点,节点e赋值为value
Status CreateBiTree (BiTree &T);//按定义构造二叉树T
Status PreOrderTraverse ( BiTree T/*,Status (*Visit)(TElemType e) */); //前序遍历
Status InOrderTraverse ( BiTree T/*,Status (*Visit)(TElemType e) */);//中序遍历
Status PostOrderTraverse ( BiTree T/*,Status (*Visit)(TElemType e) */);//后序遍历
Status LevelOrderTraverse ( BiTree T/*,Status (*Visit)(TElemType e) ,int MaxSize*/ );//层序遍历
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -