
数据结构上机
浮生之居士
转战稀土掘金:BoatingNoSay
展开
-
图的深度优先遍历和广度优先遍历
图的深度优先遍历#include<iostream>#include<cstdio>#include<cstdlib> using namespace std;#define MaxValue 32700const int NumEdges = 50; //边条数const int NumVertices = 10; //顶点个数typedef char Verte原创 2017-11-20 14:23:08 · 323 阅读 · 0 评论 -
双向循环链表基本操作
双向循环链表网上弄来的代码,可以说很优秀了。#include <stdio.h>#include <stdlib.h>#include <malloc.h>#include <ctype.h>#define LIST_ELEM_TYPE int /*链表元素数据类型*/LIST_ELEM_TYPE largest=1 ;/*链表节点类型*/typedef struct原创 2017-12-22 14:54:50 · 783 阅读 · 0 评论 -
UVa673(数据结构 栈)
673 - Parentheses Balance You are given a string consisting of parentheses () and []. A string of this type is said to be correct: (a) if it is the empty string (b) if A and B are correct, AB is cor原创 2017-02-13 11:54:12 · 259 阅读 · 0 评论 -
归并排序
#include<iostream>#include<algorithm>#include<cstdio>using namespace std;typedef int SortData;void merge ( SortData InitList[ ], SortData mergedList[ ], int left, int mid, int...原创 2018-04-24 10:47:54 · 146 阅读 · 0 评论 -
堆排序
堆 ( Heap )设有一个关键字集合,按完全二叉树的顺序存储方式存放在一个一维数组中。对它们从根开始,自顶向下,同一层自左向右从 1开始连续编号。若满足 Ki <= K2i && Ki <= K2i+1 或 Ki >= K2i && Ki>= K2i+1, 则称该关键字集合构成一个堆。 前者成为最小堆,后者称为最大堆。利用堆及其运算, 可原创 2017-12-28 09:15:00 · 200 阅读 · 0 评论 -
希尔排序
设待排序对象序列有 n 个对象, 首先取一个整数 gap < n 作为间隔, 将全部对象分为 gap 个子序列, 所有距离为 gap 的对象放在同一个子序列中, 在每一个子序列中分别施行直接插入排序。然后缩小间隔 gap, 例如取 gap = gap/2,重复上述的子序列划分和排序工作。直到最后取 gap == 1, 将所有对象放在同一个序列中排序为止。#include<iostream>原创 2017-12-28 09:12:04 · 157 阅读 · 0 评论 -
快速排序
简单 不说废话 直接放代码#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>using namespace std;#define MAXSIZE 200typedef struct { int r[MAXSIZE+1]; int length;} SqList;int Partitio原创 2017-12-27 23:00:33 · 214 阅读 · 0 评论 -
邻接矩阵 邻接链表 转换
#include <stdio.h>#include <malloc.h>//#include "graph.h" #include<iostream>using namespace std;typedef int InfoType;#define MAXV 100 //最大顶点个数#define INF 32767 //INF转载 2017-11-23 09:54:28 · 2236 阅读 · 0 评论 -
数据结构上机——哈夫曼树 线索二叉树
哈夫曼树#include<stdio.h>#include<stdlib.h>#include<string.h>#define N 5 //叶子节点数#define M 2*N-1 //哈夫曼树结点#define MAX 10000typedef char TElemType;//三叉链表typedef struct { unsigned int weight;转载 2017-11-20 14:36:36 · 362 阅读 · 0 评论 -
Prim 算法
按照课件的思路整合的代码,哈哈#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;#define MaxValue 32700const int NumEdges = 50; //边条数const int NumVertices = 10; //顶点个数typedef char原创 2017-11-20 23:38:18 · 213 阅读 · 0 评论 -
数据结构上机1——线性表
实现顺序表的以下基本操作1.创建一个顺序表2.向顺序表中插入元素3.删除顺序表中的某个元素4.查找顺序表中的元素(按值找、按序号找)5.输出顺序表中的元素 注意观察分析所写算法的复杂度#include<stdio.h> #include<stdlib.h> #define MAXSIZE 1000 struct List //顺序表结构体{原创 2017-10-30 13:59:50 · 884 阅读 · 0 评论 -
数据结构上机2——链表
实现链表的以下基本操作1.创建一个链表(头插法、尾插法)2.向链表中插入元素3.删除链表中的某个元素4.查找链表中的元素(按值找、按序号找)5.输出链表中的元素 注意链表里指针的指向#include<stdio.h> #include<stdlib.h> typedef int ListData; //此链表带表头原创 2017-10-30 14:03:27 · 334 阅读 · 0 评论 -
数据结构上机3——循环链表
循环链表的基本操作:#include<stdio.h> #include<stdlib.h> typedef char ListData;typedef struct dnode { ListData data; struct dnode * prior, * next; } DblNode;typedef Db原创 2017-10-30 14:08:56 · 251 阅读 · 0 评论 -
数据结构上机——KMP算法
#include<stdio.h> #include<stdlib.h> #define OVERFLOW -2#define ERROR -1#define OK 1#define MAXSIZE 255 typedef unsigned char SString[MAXSIZE+1];//类型定义 int next[20];void get_next(SString P, int原创 2017-11-20 14:25:42 · 337 阅读 · 0 评论 -
数据结构上机——栈
#include<stdio.h> #include<stdlib.h> #define ERROR -1#define OK 1typedef char SElemType;typedef int Status;typedef struct LNode{ SElemType data; struct LNode *next;} *SLink;typede原创 2017-11-20 14:31:20 · 402 阅读 · 0 评论 -
数据结构上机——队列
#include<stdio.h> #include<stdlib.h> #define OVERFLOW -2#define ERROR -1#define OK 1typedef struct QNode{ char data; struct QNode *next;}QNode,*QueuePtr;typedef struct {//表头节点 Queue原创 2017-11-20 14:39:48 · 298 阅读 · 0 评论 -
数据结构上机——数组、矩阵转置
#include<iostream>#include<stdarg.h>#include<cstdio>#include<cstdlib> using namespace std;#define MAX_ARRAY_DIM 8typedef int ElemType;typedef struct _ARRAY_{ ElemT...原创 2017-11-20 14:42:23 · 399 阅读 · 0 评论 -
数据结构上机——二叉树
#include <iostream>#include<stdio.h> #include<stdlib.h> using namespace std;typedef char TelemType;typedef struct BinaryTreeNode { TelemType data; struct BinaryTreeNode *Left; struct Bi原创 2017-11-20 14:48:53 · 542 阅读 · 0 评论 -
数据结构上机——图(第一次)
#include<iostream>#include<cstdio>#include<cstdlib>#include<queue>using namespace std;#define MaxValue 32700const int NumEdges = 50; //边条数const int NumVertices = 10; //顶点个数typedef cha原创 2017-11-23 10:04:54 · 665 阅读 · 0 评论