随笔分类 -  数据结构

1
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 struct BinaryTreeNode 9 { 10 int m_nValue; 11 ... 阅读全文
posted @ 2014-09-07 13:39 CrazyCode. 阅读(312) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 struct ListNode 8 { 9 //结点类型 10 int m_nValue; ... 阅读全文
posted @ 2014-09-07 10:30 CrazyCode. 阅读(285) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2014-03-06 13:58 CrazyCode. 阅读(233) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef char VertexType; 8 typedef int EdgeType; 9 const int MAXVEX = 100; 10 const int INFINITY = 65535; 11 int visited[MAXVEX]; 12 class EdgeNode 13 { 14 public: 15 int adjvex; 16 EdgeType weigh... 阅读全文
posted @ 2014-03-06 09:52 CrazyCode. 阅读(977) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 5 using namespace std; 6 7 typedef char VertexType; 8 typedef int EdgeType; 9 const int MAXVEX = 100; 10 const int INFINITY = 65535; 11 12 class MGraph 13 { 14 public: 15 VertexType vex[MAXVEX];//顶点表 16 EdgeType arc[MAXVEX][MAXVEX]... 阅读全文
posted @ 2014-03-06 01:32 CrazyCode. 阅读(1691) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 /*排序用到的结构*/ 7 const int maxSize = 10; 8 typedef struct 9 {10 int r[maxSize+1];11 int length;12 }SqList;13 14 /*数组元素交换*/15 void swap(SqList *L,int i ,int j)16 {17 int temp = L->r[i];18 L->r[i] = L->r[j];19 ... 阅读全文
posted @ 2014-02-16 17:30 CrazyCode. 阅读(152) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 /*排序用到的结构*/ 7 const int maxSize = 10; 8 typedef struct 9 {10 int r[maxSize+1];11 int length;12 }SqList;13 14 /*数组元素交换*/15 void swap(SqList *L,int i ,int j)16 {17 int temp = L->r[i];18 L->r[i] = L->r[j];19 ... 阅读全文
posted @ 2014-02-16 16:52 CrazyCode. 阅读(208) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 /*散列表查找实现 7 散列表如果没有冲突,查找效率就非常高的.时间复杂度是O(1);但是实际应用中,冲突是不可避免的. 8 那么散列表的平均查找长度取决于 9 1.散列函数是否均匀.10 2.处理冲突的方法.11 3.散列表的装填因子.a = 填入表中的记录个数 / 散列表的长度.当a越大,产生冲突的可能性就越大.12 用空间来换取时间13 */14 const int success = 1;15 const int unSucc 阅读全文
posted @ 2014-02-16 15:56 CrazyCode. 阅读(359) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 /* 9 二叉排序树:又称为二叉查找树,它或者是一棵空树,或者具有如下性质:10 1.若他的左子树不空,则左子树上所有结点的值均小于它的根结点的值.11 2.若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值.12 3.它的左右子树也分别为二叉排序树.13 如中序遍历,则可获得有序序列.14 */15 16 typedef struct BiTNode17 {18 int data;19 st... 阅读全文
posted @ 2014-02-16 15:19 CrazyCode. 阅读(217) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 /*有序表查找-折半查找 9 折半查找有称为二分查找,线性表中的记录必须是关键码有序,通常是从小到大10 线性表必须采用顺序存储.11 基本思想:在有序表中,取中间记录作为比较对象,若给定值与中间记录的关键字相等,则查找成功;12 若给定值小于中间记录的关键字,则在中间记录的左半区继续查找;若给定值大于中间记录的关键字,13 则在中间记录的右半区继续查找。不断重复上述过程.直到找到成功,或所有查找区域无记录, 阅读全文
posted @ 2014-02-15 15:51 CrazyCode. 阅读(1029) 评论(0) 推荐(0)
摘要:a为数组,n为要查找的数组个数,key为要查找的关键字.顺序查找又称为线性查找:从表中第一个或者最后一个记录开始,逐个进行记录的关键字和给定值比较,若某个记录的关键字和给定值相等,则查找成功,找到所查记录;如果直到最后一个(或第一个)记录,其关键字和给定值比较都不等的时候.则表中没有所查的记录,查找不成功. 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 //顺序表查找的两种方法 9 int Sequential_Search(int *a,int n,i 阅读全文
posted @ 2014-02-15 15:29 CrazyCode. 阅读(313) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef char VertexType;//顶点类型 8 typedef int EdgeType;//权值类型 9 const int maxVex = 100; 10 typedef struct EdgeNode//边表 11 { 12 int adjvex; 13 EdgeType weight; 14 struct EdgeNode *next; 15 }EdgeN... 阅读全文
posted @ 2014-02-12 19:50 CrazyCode. 阅读(2627) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 //邻接矩阵存储结构 7 typedef char VertexType; 8 typedef int EdgeType;//权值类型 9 const int maxVex = 100;//最大顶点数10 const int inFinity = 65535;//代表无穷大11 typedef struct 12 {13 VertexType vexs[maxVex];//顶点表14 EdgeType arc[ma. 阅读全文
posted @ 2014-02-12 11:21 CrazyCode. 阅读(1529) 评论(0) 推荐(0)
摘要:其实建立的方式和遍历是一个意思.也是利用了递归的原理.只不过在原来应该是输出结点的地方,改成了生成结点,然后给这个结点进行赋值操作。所以理解了遍历就很容易理解建立. 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 typedef char TElemType; 9 typedef int Status; 10 const int ok = 1; 11 const int error = 0; 12 typedef struct BiTNode 13 ... 阅读全文
posted @ 2014-02-11 14:41 CrazyCode. 阅读(213) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //循环队列的顺序存储结构 7 8 typedef int Status; 9 const int ok = 1;10 const int error = 0;11 const int maxSize = 5;12 13 typedef int QElemType;14 15 typedef struct QNode16 {17 QElemType data;18 struct QNode *next;19 }QNode,*Qu... 阅读全文
posted @ 2014-02-09 19:34 CrazyCode. 阅读(936) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //循环队列的顺序存储结构 7 typedef int QElemType; 8 typedef int Status; 9 const int ok = 1;10 const int error = 0;11 const int maxSize = 5;12 13 typedef struct 14 {15 QElemType data[maxSize];16 int front;17 int rear;18 }SqQu... 阅读全文
posted @ 2014-02-09 17:51 CrazyCode. 阅读(594) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //栈的链式存储结构及实现 7 //栈的结构定义 8 #define OK 1 9 #define ERROR 010 #define TRUE 111 #define FALSE 012 typedef int sElemType;13 typedef int Status;14 15 16 typedef struct StackNode17 {18 sElemType data;19 struct StackNode *ne.. 阅读全文
posted @ 2014-02-08 17:15 CrazyCode. 阅读(2645) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //栈的顺序存储结构及实现 7 //栈的结构定义 8 #define OK 1 9 #define ERROR 010 #define TRUE 111 #define FALSE 012 #define MAXSIZE 513 typedef int sElemType;14 typedef int Status;15 typedef struct16 {17 sElemType data[MAXSIZE];18 int top.. 阅读全文
posted @ 2014-02-08 16:06 CrazyCode. 阅读(664) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //一系列状态 7 #define OK 1 8 #define ERROR 0 9 #define TRUE 1 10 #define FALSE 0 11 typedef int Status; 12 13 //线性表的顺序存储 14 #define MAXSIZE 20 15 typedef int ElemType; 16 typedef struct 17 { 18 ElemType data[MAXSIZE... 阅读全文
posted @ 2014-02-08 14:53 CrazyCode. 阅读(259) 评论(0) 推荐(0)
摘要:逻辑结构与物理结构 逻辑结构:1.集合结构.2.线性结构.3.树形结构.4.图形结构 物理结构:是指数据的逻辑结构在计算机中的存储形式 1.顺序存储结构:把数据元素存放在地址连续的存储单元里,其数据间的逻辑关系和物理关系是一致的. 2.链式存储结构:是把数据元素存放在任意的存储单元里,这组存储单元可以是连续的,也可以是不连续的.数据元素的存储关系并不能反映其逻辑关系,因此需要用一个指针存放... 阅读全文
posted @ 2013-10-27 19:51 CrazyCode. 阅读(116) 评论(0) 推荐(0)

1