码迷,mamicode.com
首页 >  
搜索关键字:bintree    ( 77个结果
6-11 先序输出叶结点
6-11 先序输出叶结点(15 分) 本题要求按照先序遍历的顺序输出给定二叉树的叶结点。 函数接口定义: void PreorderPrintLeaves( BinTree BT ); 其中BinTree结构定义如下: typedef struct TNode *Position; typedef ...
分类:其他好文   时间:2018-01-31 22:17:21    阅读次数:218
6-9 二叉树的遍历
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
【数据结构】二叉树(c++)
头文件: #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分)
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
算法9---算法9---二叉树的遍历
在这里我们理一遍二叉树的递归和非递归遍历 一.前序遍历 前序遍历按照“根结点-左孩子-右孩子”的顺序进行访问。 1.递归实现 1 void preOrder1(BinTree *root) //递归前序遍历 2 { 3 if(root!=NULL) 4 { 5 cout<<root->data<<" ...
分类:编程语言   时间:2016-09-20 23:53:27    阅读次数:175
77条   上一页 1 2 3 4 5 6 ... 8 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!