![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构算法
文章平均质量分 70
无_名_
将相本无神,男儿当自强。
展开
-
数据结构---串
串的基本运算下面是我的代码实现:#include #include static const int Maxlen = 100;using namespace std;typedef struct{ char ch[Maxlen]; int len;}String;class S{ public: S(){原创 2013-06-09 21:06:16 · 771 阅读 · 0 评论 -
拓扑排序算法
对许多数据结构教材实在不满意,至少我是看不懂……至于拓扑排序算法,教材上那些伪代码真真教人头晕。只写了几个struct结构,我根本看不出这是邻接表。如果给出一个清晰明了的图,一切不就简单了?总之,关键就是建立一个邻接表。然后利用这个表进行拓扑排序。//边表结点声明typedef struct EdgeNode{ int adjvex; s转载 2013-07-22 10:21:19 · 903 阅读 · 0 评论 -
比赛日程安排程序
比赛日程安排程序设计的关键在于理解分治法,和递归。另外将日程分治后,又要考虑如何将分开的日程合并,这就需要程序设计者自己观察,总结规律。//比赛日程安排#include #define MAXN 64int a[MAXN][MAXN + 1] = {0};void gamecal (int k, int n) //处理k开始的n个选手的日程{ int i,原创 2013-07-24 09:44:13 · 1589 阅读 · 0 评论 -
八皇后问题求解
#include #include int State[8];int count = 0;class Queen{ public: void EightQueen(int n); //求解八皇后的主干程序 void ShowAnswer(); //用于输出结果 int Chec原创 2013-07-28 07:04:03 · 884 阅读 · 0 评论 -
迷宫问题求解
如果理解了栈,并会应用栈来解决问题,这个迷宫的问题并不难。主要就是不断的探路,将可行路径入栈,走不下去就出栈,继续由栈顶元素寻找新路。代码写的不算完美,但答案是正确的。不过按这个方法是没法找最优解的。/*求解迷宫问题2013.8.31by无名*/#include using namespace std;const int M = 8;const原创 2013-08-31 13:29:20 · 1078 阅读 · 0 评论 -
随便写了个快速排序程序
#include using namespace std;int InsertSort(int num[],int low,int high){ int piov = 0; num[piov] = num[low]; while(low < high) { while(low num[piov]) high--; num[low] = num[原创 2014-01-08 08:35:01 · 9659 阅读 · 0 评论 -
选择排序很简单
#include using namespace std;int main(){ printf("输入"); int thenum[11]; int i; for(i = 1; i < 11; i++) { cout << "输入第" << i << "个数" ; cin>>thenum[i]; } int j; int jj; for(i = 1; i <原创 2014-01-08 08:36:40 · 689 阅读 · 0 评论 -
随便写了个堆排序程序
#include using namespace std; void HeapAdjust(int num[],int low,int high){ int temp; //用于交换数据 temp = num[low]; for(int i = 2*low; i <= high; i *= 2){ if(i原创 2014-01-12 10:59:26 · 1016 阅读 · 0 评论 -
基数排序
排序算法写了n种,可不像孔乙己一样考验"茴香豆"的"茴"字有几种写法,而是思维的一种拓展,等到使用的时候根据特定的场景变能灵活的选取更加合适的算法。今日所记录的是基数排序。一. 算法描述基数排序(以整形为例),将整形10进制按每位拆分,然后从低位到高位依次比较各个位。主要分为两个过程:(1)分配,先从个位开始,根据位值(0-9)分别放到0~9号桶中(比如53,个位为转载 2014-01-18 09:34:22 · 750 阅读 · 0 评论 -
指令流水线的计算
若每一条指令都可以分解为取指、分析和执行三步。已知取指时间t取指=4△t,分析时间t分析=3△t,执行时间t执行=5△t。如果按串行方式执行完100条指令需要 (2) △t。如果按照流水方式执行,执行完100条指令需要(3) △t。(2)A.1190 B.1195 C.1200 D.1205 (3)A.504 B.507 C.508 D.510试题解析: 串行执行时,总执行时间=1转载 2014-08-19 21:02:32 · 2467 阅读 · 0 评论 -
二叉树基本操作--java实现
public class Node { //node class, the base of tree int data; int index; Node leftChild; Node rightChild;}原创 2014-08-22 22:40:39 · 685 阅读 · 0 评论 -
线索二叉树
#include #include#define LEN sizeof(struct ThreadBinTree)#define NULL 0enum NodeFlag{ SubTree, Thread}; //枚举值SubTree和Thread分别为0,1struct原创 2013-06-19 13:38:44 · 600 阅读 · 0 评论 -
KMP算法
KMP匹配算法对我来说很复杂。目前只是有一些了解。 2013.6.10KMP算法远没有想象中那么难。要理解KMP算法,只需要理解这个就行了。以abaabcac为例j 1 2 3 4 5 6 7 8--------------------------模式串 a b a a b c原创 2013-07-03 20:43:15 · 653 阅读 · 0 评论 -
约瑟夫环问题
#include#include#define NULL 0#define LEN sizeof(struct Josephus)struct Josephus{ int num; struct Josephus *next;};void main(){ printf("约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在"); printf(原创 2013-06-05 20:30:18 · 1029 阅读 · 0 评论 -
排序法总结
首先记录一些基本的概念。1.排序方法的稳定性。假设i<j,且在排序前的序列中Ri领先于Rj,则称所用的排序方法是稳定的;反之,若可能使排序后的序列中Rj领先于Ri,则称所用的排序方法是不稳定的。(这是严蔚敏书上的原话,怎么感觉像是什么都没说一样。)2.内部排序。待排序记录在存放在计算机随机存储器中进行的排序过程。3.外部排序。待排序记录数量很大,以致内存一次不能容纳全部记录原创 2013-06-16 14:42:50 · 578 阅读 · 0 评论 -
二叉树的基本操作
#include#include#define LEN sizeof(struct ChainTree)#define NULL 0struct ChainTree{ int num; struct ChainTree *left; struct ChainTree *right;};/*函数功能:进行查找操作。*/ChainTree *BinTreeFind(ChainTr原创 2013-06-19 13:24:52 · 706 阅读 · 0 评论 -
串
#include #include static const int Maxlen = 100;using namespace std;typedef struct{ char ch[Maxlen]; int len;}String;class S{ public: S(){ //构造原创 2013-06-19 13:26:20 · 567 阅读 · 0 评论 -
非连通图生成树遍历
#include #include #define LEN sizeof(struct MatrixGraph)#define TEN sizeof(struct MatrixGraph)#define VERTEX_MAX 26#define MAXVALUE 32767struct MatrixGraph{ int Vertex[VERTEX_MAX];原创 2013-07-13 14:11:22 · 1632 阅读 · 0 评论 -
邻接矩阵深度优先遍历
#include#define VERTEX_MAX 26#define MAXVALUE 32767struct MatrixGraph{ int Vertex[VERTEX_MAX]; //保存顶点信息(序号或字母) int Edges[VERTEX_MAX][VERTEX_MAX];原创 2013-06-27 18:00:09 · 1758 阅读 · 0 评论 -
广度优先遍历
#include #include #define LEN sizeof(struct MatrixGraph)#define VERTEX_MAX 26#define MAXVALUE 32767struct MatrixGraph{ int Vertex[VERTEX_MAX]; //保存顶点信息原创 2013-06-29 08:54:08 · 667 阅读 · 0 评论 -
最小生成树
#include#include#include#define MAX_VERTEX_NUM 20#define OK 1#define ERROR 0#define MAX 1000typedef struct Arcell{ double adj;}Arcell,AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];typedef st转载 2013-07-13 14:36:04 · 1003 阅读 · 0 评论 -
图---最短路径
#include#define VERTEX_MAX 26#define MAXVALUE 32767struct MatrixGraph{ int Vertex[VERTEX_MAX]; //保存顶点信息(序号或字母) int Edges[VERTEX_MAX][VERTEX_MAX];原创 2013-07-19 09:23:44 · 899 阅读 · 1 评论 -
Huffman编码---java实现
算法是准确的,目前程序还有一点点小bug原创 2014-08-22 22:44:56 · 1636 阅读 · 0 评论