6-11 先序输出叶结点(15 分) 本题要求按照先序遍历的顺序输出给定二叉树的叶结点。 函数接口定义: void PreorderPrintLeaves( BinTree BT ); 其中BinTree结构定义如下: typedef struct TNode *Position; typedef ...
分类:
其他好文 时间:
2018-01-31 22:17:21
阅读次数:
218
6-9 二叉树的遍历(25 分) 本题要求给定二叉树的4种遍历。 函数接口定义: void InorderTraversal( BinTree BT ); void PreorderTraversal( BinTree BT ); void PostorderTraversal( BinTree B ...
分类:
其他好文 时间:
2018-01-31 16:09:07
阅读次数:
148
// 先序遍历非递归 public static void preOrder2(BinTree t) { Stack s = new Stack(); while (t != null || !s.empty()) { while (t != null) { ... ...
分类:
其他好文 时间:
2017-09-06 19:32:09
阅读次数:
108
头文件: #include <iostream> using namespace std; template<class Type> class Bintree; //结点类 template<class Type> class BintreeNode { friend class Bintree< ...
分类:
编程语言 时间:
2017-05-19 16:48:55
阅读次数:
244
import java.util.Stack; import java.util.HashMap; public class BinTree { private char date; private BinTree lchild; private BinTree rchild; public Bin... ...
分类:
编程语言 时间:
2017-05-04 13:21:46
阅读次数:
180
1 typedef struct TreeNode *BinTree; 2 typedef BinTree Position; 3 struct TreeNode{ 4 ElementType Data; 5 BinTree Left; 6 BinTree Right; 7 }; 8 BinTree... ...
分类:
其他好文 时间:
2017-02-09 22:02:56
阅读次数:
175
1 typedef struct TreeNode *BinTree; 2 typedef BinTree Position; 3 struct TreeNode{ 4 ElementType Data; 5 BinTree Left; 6 BinTree Right; 7 }; 8 BinTree... ...
分类:
编程语言 时间:
2017-02-09 21:52:42
阅读次数:
219
4-8 求二叉树高度 (20分) 本题要求给定二叉树的高度。 函数接口定义: 其中BinTree结构定义如下: 要求函数返回给定二叉树BT的高度值。 裁判测试程序样例: 输出样例(对于图中给出的树): 程序代码: ...
分类:
其他好文 时间:
2017-02-04 10:48:28
阅读次数:
926
1 public class BinTree { 2 private char date; 3 private BinTree lchild; 4 private BinTree rchild; 5 6 public BinTree(char c) { 7 date = c; ... ...
分类:
其他好文 时间:
2016-12-26 21:49:55
阅读次数:
227
在这里我们理一遍二叉树的递归和非递归遍历 一.前序遍历 前序遍历按照“根结点-左孩子-右孩子”的顺序进行访问。 1.递归实现 1 void preOrder1(BinTree *root) //递归前序遍历 2 { 3 if(root!=NULL) 4 { 5 cout<<root->data<<" ...
分类:
编程语言 时间:
2016-09-20 23:53:27
阅读次数:
175