//file:BTtree.h
#ifndef _BTTREE_H_HUMING_INCLUDE_
#define _BTTREE_H_HUMING_INCLUDE_
#include<iostream>
#include<queue>
#include<stack>
#define maxlen 1002
using namespace std;
template <class T>
class treenode
{
public:
treenode():lchild(-1),rchild(-1) {}; //构造函数
~treenode() {}; //析构函数
T data;
int lchild,rchild;
};
template <class T>
class BTtree
{
public:
BTtree():root(-1),nodenum(0) {}; //构造函数,树为空,开始的时候没有元素
~BTtree() {};//析构
void pre_create(); //建立二叉树
int Lchild(int t);//返回右儿子位置
int Rchild(int t); //返回儿子位置
T elements(int t); //返回下标所对应元素
bool Isempty(); //判空
int return_root(); //返回根节点下标
void pre_order(int t);//先序递归
void in_order(int t);//中序递归
void post_order(int t);//后序递归
void nrec_pre_order(int t);//先序非递归
void nrec_in_order(int t);//中序非递归
void nrec_post_order(int t);//后序非递归
void level_order(int t);//层序遍历
//几个遍历函数@
priva
二叉树-----静态二叉链表(游标)-----建立(先序)+遍历(7种)
最新推荐文章于 2023-09-14 17:19:12 发布