b站王道考研-数据结构5.3_2二叉树遍历实现-代码-CSDN博客(王道考研视频每年都一样吗)

包含二叉树的先序、中序、后序以及层次遍历。

共包含两个文件bitree_test.cpp和liqueue_test.cpp

一、文件一bitree_test.cpp

? ? ? ? 包含二叉树遍历的逻辑结构其中二叉树结点的存储结构放在文件二中。

#include<stdio.h>
#include<iostream>
#include
}

二、文件二liqueue_test.cpp

? ? ? ? 主要包含队列的逻辑结构在二叉树的层次遍历中需要辅助队列的 助。

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;

typedef struct bitnode{
int data;
struct bitnode *lchild,*rchild;
}bitnode,*bi

tree;

#define elemtype bitnode*
//链式队列
typedef struct linknode{
elemtype node;
struct linknode *next;
}linknode;
typedef struct{
linknode *front,*rear;//队列队头指针
}

评论