北邮 信通院 数据结构 实验三实践-题目1 二叉树

北邮 信通院 数据结构 实验三实践-题目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;
}

  • 30
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值