后序线索二叉树

 线索二叉树,就好像是给排列在不同地方的对象用一根无形的绳子穿起来了,变成了“线形”的,这样每个结点的前驱和后继就能直接得到或者容易找到了。
线索化的过程需要用到遍历算法,一旦线索建立后,在此结构上遍历就可以不用递归、也不用栈了,实现更加容易了

 

头文件 BitTree.h

#ifndef BITTREE_H
#define BITTREE_H
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
typedef enum{Link,Thread} PointTag;
typedef char Element;
typedef int Status;
typedef struct Node{
	Element data;
	struct Node* left;
	struct Node* right;
	PointTag Ltag;
	PointTag Rtag;
}BitNode,*BitTree;
Status visit(Element e);
Status CreateTree(BitTree &T);
void InThreading(BitTree p);
void InOrderThreading(BitTree &H,BitTree T);
BitTree Parent(BitTree Thr,BitTree p);
void InOrderTraverse_Thr(BitTree L);
#endif //BITTREE_H


实现文件 BitTree.cpp

#include "BitTree.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
BitTree pre;
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值