北邮 信通院 数据结构 实验三实践-题目1 二叉树
根据二叉树的抽象数据类型的定义,使用二叉链表实现一个二叉树
仅供学习交流使用
#include<iostream>
#include<stack>
#include "Tree.h"
using namespace std;
int main()
{
char m;
/*for (int i = 0; i < n; i++)
{
cin >> data[i];
}*/
//BiTree<char>BiTree(R);
BiNode<char>*R = NULL;
BiNode<char>*p = NULL;
BiTree<char> myT;
BiNode<char>*root = myT.Create(R);
cout << "输出想要路径的结点值:";
cin >> m;
cout << "该二叉树的前序遍历为:" << endl;
myT.PreOrder(root);
cout << endl;
cout << "该二叉树的中序遍历为:" << endl;
myT.InOrder(root);
cout << endl;
cout << "该二叉树的后续遍历为:" << endl;
myT.PostOrder(root);
cout << endl;
cout << "该二叉树的层序遍历为:" << endl;
myT.LevelOrder(root);
cout << endl;
cout << "该二叉树的深度为:"; cout << myT.TreeDepth(root);
cout << endl;
cout << "从根结点到该结点的路径为:";
BiNode<char>*target = myT.Find(root, p, m);
myT.NodePath(root, target);
cout << endl;
myT.~BiTree();
system("pause");
return 0;
}