二叉树的层序遍历
摘要:1 typedef struct TreeNode *BinTree; 2 typedef BinTree Position; 3 struct TreeNode{ 4 ElementType Data; 5 BinTree Left; 6 BinTree Right; 7 }; 8 BinTree BT; 9 void LevelOrder...
阅读全文
posted @
2017-02-09 20:43
chy89224
阅读(145)
推荐(0)
二叉树的中序、先序、后序遍历非递归遍历算法(使用堆栈,用循环实现)
摘要:1 typedef struct TreeNode *BinTree; 2 typedef BinTree Position; 3 struct TreeNode{ 4 ElementType Data; 5 BinTree Left; 6 BinTree Right; 7 }; 8 BinTree BT; 9 void InOrderTr...
阅读全文
posted @
2017-02-09 20:39
chy89224
阅读(348)
推荐(0)
二叉树的先序、中序、后序遍历
摘要:typedef struct TreeNode *BinTree; typedef BinTree Position; struct TreeNode{ ElementType Data; BinTree Left; BinTree Right; }; BinTree BT; //二叉树的遍历 void PreOrderTraversal(BinTree BT)//(1)先序遍历 ...
阅读全文
posted @
2017-02-05 04:03
chy89224
阅读(219)
推荐(0)
二叉树的存储结构
摘要:typedef struct TreeNode *BinTree; typedefBinTree Position; struct TreeNode{ ElementType Data; BinTree Left; BinTree Right; }; BinTree BT;
阅读全文
posted @
2017-02-05 04:01
chy89224
阅读(133)
推荐(0)
数据管理基本操作-查找
摘要:typedef struct LNode *List; struct LNode{ ElementType Element[MAXSIZE]; int Length; }; 方法1:顺序查找算法 int SequentialSearch(List Tb1,ElementType K)//(有"哨兵"
阅读全文
posted @
2017-02-04 04:08
chy89224
阅读(206)
推荐(0)
一元多项式加法与乘法运算链表实现
摘要:typedef struct PolyNode *Polynomial; struct PolyNode{ int coef;//系数 int expon;//指数 Polynomial link;/*指向下一个结点的指针*/ }; Polynomial P,Rear,t1,t2,t;//这句一定要写 int main() { Polynomial P1,P2,PP,PS; ...
阅读全文
posted @
2017-01-29 01:56
chy89224
阅读(417)
推荐(0)
多项式加法运算链表实现
摘要:struct PolyNode{ int coef;//系数 int expon;//指数 struct PolyNode *link;//指向下一个结点的指针 }; typedef struct PolyNode *Polynomial; Polynomial P1,P2; Polynomial
阅读全文
posted @
2017-01-18 19:25
chy89224
阅读(2173)
推荐(0)
队列的链表存储实现
摘要:struct Node{ ElementType Data; struct Node *Next; }; struct QNode{//链队列结构 struct Node *rear; //指向队尾结点 struct Node *front;//指向队头结点 }; typedef struct QN
阅读全文
posted @
2017-01-18 16:25
chy89224
阅读(236)
推荐(0)
队列的顺序存储实现
摘要:#define MaxSize <储存数据元素的》最大个数> struct QNode{ ElementType Data[MaxSize]; int rear; int front; }; typedef struct QNode *Queue; void AddQ(Queue PtrQ,Elem
阅读全文
posted @
2017-01-18 15:45
chy89224
阅读(194)
推荐(0)
栈的链表存储实现
摘要:typedef struct SNode *Stack; struct SNode{ ElementType Data; struct SNode *Next; }; Stack CreateStack() {//构建一个堆栈的头结点,返回指针 Stack S; S=(Stack)malloc(si
阅读全文
posted @
2017-01-17 22:30
chy89224
阅读(155)
推荐(0)
栈的顺序存储实现
摘要:#define MaxSize <储存数据元素的最大个数> typedef struct SNode *Stack; struct SNode{ ElementType Data[MaxSize]; int Top; }; void Push(Stack PtrS,ElementType item)
阅读全文
posted @
2017-01-17 21:47
chy89224
阅读(160)
推荐(0)
广义表
摘要:typedef struct GNode*GList; struct GNode{ int Tag;//标志域:0表示结点是单元素,1表示结点是广义表 union{ //子表指针域Sublist与单元素数据域Data复用,即共用存储空间 ElementType Data; GList SubList
阅读全文
posted @
2017-01-17 15:43
chy89224
阅读(144)
推荐(0)
线性表的链表存储实现
摘要:typedef struct LNode *List; struct LNode{ ElementType Data; List Next; }; struct LNode L; List PtrL; int Length(List PtrL)//求表长 { List p=PtrL;//p指向表的第
阅读全文
posted @
2017-01-17 04:07
chy89224
阅读(210)
推荐(0)
线性表的顺序存储实现
摘要:typedef struct LNode *List; struct LNode{ ElementType Data[MAXSIZE]; int Last; }; struct LNode L; List PtrL; 主要操作的实现 List MakeEmpty()//初始化(建立空的顺序表) {
阅读全文
posted @
2017-01-16 22:02
chy89224
阅读(200)
推荐(0)
求最大的连续子列和
摘要:算法1 int MxaSubseqSum1(int A[],int N) {int ThisSum,MaxSum=0; int i,j,k; for(i=0;i<N;i++){//i是子列左端位置 for(j=i;j<N;j++){//j是子列右端位置 ThisSum=0;//ThisSum是从A[
阅读全文
posted @
2016-12-26 17:46
chy89224
阅读(175)
推荐(0)
计算多项式用直接算和秦九韶公式
摘要:因为程序计算太快,所以clock函数捕捉不到区别。 由最后这张图知道秦九韶公式计算多项式更快。duration2比duration1快一个数量级
阅读全文
posted @
2016-12-24 21:06
chy89224
阅读(226)
推荐(0)
算法
摘要:void SelectSort(int List[], int N) { for(i=0;i<N;i++) {// 将N个整数List[0]...List[N-1]进行非递减排序, //注排好序的部分为 List[0]...List[N-1],没 好序的部分为List[i]到List[N-1] Mi
阅读全文
posted @
2016-12-24 19:52
chy89224
阅读(120)
推荐(0)