// BTree.cpp : Defines the entry point for the console application. /* 作者:成晓旭 时间:2001年7月2日(9:00:00-14:00:00) 内容:完成二叉树的创建、前序遍历、中序遍历、后序遍历 时间:2001年7月2日(14:00:00-16:00:00) 内容:完成二叉树的叶子节点访问,交换左、右孩子 */ #include "stdafx.h" #include "stdlib.h" #defin e MAX_N
#include #include #include using namespace std; const int LH=1; //左子树比右子树高1 const int EH=0; //左右子树一样高 const int RH=-1;//右子树比左子树高1 const int MAX_NODE_NUM=20; //结点数目上限 class AvlNode { int data; int bf; //平衡因子 AvlNode *lchild; AvlNode *rchild; friend