层次遍历:即每一层从左向右输出 元素需要储存有先进先出的特性,所以选用队列存储。 队列的定义: #define MAX 1000 typedef struct seqqueue{ bintree data[MAX]; int front; int rear; }seqqueue; void ente ...
分类:
其他好文 时间:
2016-08-28 22:28:54
阅读次数:
257
3-1 BinTree.c 3-2 BinTreeTest.c ...
分类:
其他好文 时间:
2016-07-19 09:19:31
阅读次数:
221
本题要求实现给定二叉搜索树的5种常用操作。
函数接口定义:BinTree Insert( BinTree BST, ElementType X );
BinTree Delete( BinTree BST, ElementType X );
Position Find( BinTree BST, ElementType X );
Position FindMin( BinTree BST )...
分类:
其他好文 时间:
2016-07-16 01:03:39
阅读次数:
441
void preOrder2(BinTree *root) //非递归前序遍历 { stack<BinTree*> s; BinTree *p=root; while(p!=NULL||!s.empty()) { while(p!=NULL) { cout<<p->data<<" "; s.push ...
分类:
其他好文 时间:
2016-04-22 18:13:12
阅读次数:
98
void preOrder(BinTree *root) //递归前序遍历 { if(root!=NULL) { coutdatalchild); preOrder1(root->rchild); }}void inOrder1(BinTree ...
分类:
其他好文 时间:
2015-10-17 16:11:13
阅读次数:
120
算法的思想: 采用二叉树的后序遍历非递归算法。由于后序遍历非递归算法使用一个栈实现,每次都会在一条路径上走到最底层才向上访问,再向右访问。因此,记录下栈在遍历中的最大值,即为二叉树的最大深度。#include #include using namespace std;struct BinTree{....
分类:
编程语言 时间:
2015-10-08 00:37:40
阅读次数:
221
1 #include 2 #include 3 #include 4 using namespace std; 5 struct BinTree 6 { 7 int data; 8 BinTree *lc; 9 BinTree *rc; 10 }BT...
分类:
编程语言 时间:
2015-10-08 00:27:16
阅读次数:
293
/*二叉树遍历(递归版本&非递归版本)(1)中序遍历(2)先序遍历(3)后续遍历*/struct BinTree { int data; /*数据域*/ BinTree* leftchild; /*左孩子*/ BinTree* rightchild; ...
分类:
其他好文 时间:
2015-09-13 11:48:50
阅读次数:
125
二叉树的遍历主要是以二叉树的链式存储来讲。链表存储的结构:(下面会用到)typedef struct TreeNode *BinTree;typedef BinTree Position;struct TreeNode{ ElementType Data; BinTree Lef...
分类:
其他好文 时间:
2015-08-25 19:10:48
阅读次数:
161
对于一种数据结构而言,遍历是常见操作。二叉树是一种基本的数据结构,是一种每个节点的儿子数目都不多于2的树。二叉树的节点声明如下:1 typedef struct TreeNode *PtrToNode;2 typedef struct TreeNode *BinTree;3 4 struct T.....
分类:
其他好文 时间:
2015-08-21 19:28:37
阅读次数:
223