#include "stdio.h"
#include "stdlib.h"
#include "stdbool.h"
typedef int DataType;
typedef struct Node {
DataType data;
struct Node *left;
struct Node *right;
bool leftTag; // 用于标记left指针指向的是左孩子还是先驱节点
bool rightTag; // 用于标记right指针指向的是右孩子还是后继节点
} Node;
void create(int *arr, Node **pNode, int index, int len);
void preThread(Node **pNode, Node **pre);
void inThread(Node **pNode, Node **pre);
void inOrder(Node *pNode);
Node *findNextNode(Node *pNode);
Node *findLeftMostNode(struct Node *pNode);
void preOrder(Node *pNode);
int main() {
// 数据的节点数组,空间点使用-1表示
DataType treeArr[] = {
1, 2, 3, 4, 5};
int *ptr = treeArr;
/**********************前序线索化以及前序线索二叉树的遍历*****************************/
Node *tree = NULL;
create(ptr, &tree, 1, 5); // 构建一个线索二叉树
// 线索化
Node *pre = NULL; // 指向当前访问节点的前驱节点
preThread
数据结构------前序、中序线索化二叉树及遍历(C/C++)
最新推荐文章于 2022-10-30 16:52:22 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)