摘要: 栈是常用的数据结构之一,下面给出一个链式栈的实现~~头文件Stack.h#ifndef Stack_H#define Stack_Htypedef int Item;typedef struct node * PNode;/*定义栈节点类型*/typedef struct node{ Item data; PNode down;}Node;/*定义栈类型*/typedef struct stack{ PNode top; int size;}Stack;/*构造一个空栈*/Stack *InitStack();/*销毁一个栈*/void DestroyStack(Sta... 阅读全文
posted @ 2013-11-06 23:16 stemon 阅读(564) 评论(0) 推荐(0) 编辑
摘要: 队列是常用的数据结构之一,下面给出一个链式队列的实现:头文件Queue.h 1 #ifndef Queue_H 2 #define Queue_H 3 4 typedef int Item; 5 typedef struct node * PNode; 6 typedef struct node 7 { 8 Item data; 9 PNode next;10 }Node;11 12 typedef struct13 {14 PNode front;15 PNode rear;16 int size;17 }Queue;18 19 /*构造一个空队列*... 阅读全文
posted @ 2013-11-06 23:09 stemon 阅读(1727) 评论(0) 推荐(0) 编辑
摘要: 二叉树的所有的操作基本上都是跟遍历相关的,二叉树的深度遍历(先序、中序、后序)都设计栈的操作,但是二叉树的广度搜索(层次遍历)用到的就是队列的操作。注意一点,二叉树的层次的遍历要得到的结果是把所有的信息放到一个一维的数组中,还是放到一个二维的数组中。遍历结果存储到一维数组中vector PrintF... 阅读全文
posted @ 2013-11-06 23:05 stemon 阅读(937) 评论(0) 推荐(0) 编辑