![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
dazhi316
这个作者很懒,什么都没留下…
展开
-
链表实现
<br />#include <iostream>using namespace std;//链表的创建、查找、删除、增加元素struct node{ char ch; node *next;};bool createList(node* &head){ head = new node; head->ch = 'S'; head->next = NULL; char ch; cin.get(ch);原创 2010-11-10 10:42:00 · 365 阅读 · 0 评论 -
二叉树实现
<br />#include <iostream>#define MAX 1024using namespace std;struct node{ char ch; node *lefchild,*rightchild;};//建立二叉树void createBitree(node* &bitree){ char ch; cin.get(ch); bitree = new node; if(ch == ' ')原创 2010-11-10 10:49:00 · 357 阅读 · 0 评论 -
图--邻接矩阵
<br />#include <iostream>#define MAX_VERTEX_NUM 1024#define INFINITY 0using namespace std;typedef enum {DG,DN,UDG,UDN} GraphKind;typedef struct{ char vertex[MAX_VERTEX_NUM]; int Arc[MAX_VERTEX_NUM][MAX_VERTEX_NUM]; int vexNum原创 2010-11-12 08:11:00 · 614 阅读 · 0 评论 -
图的邻接表
<br />#include <iostream>#define MAX_VERTEX_NUM 1024using namespace std;typedef struct ArcNode{ int adjvex; ArcNode *nextarc;}ArcNode;typedef struct VNode{ char data; ArcNode *firstarc;}VNode, AdjList[MAX_VERTEX_NUM];t原创 2010-11-14 14:13:00 · 531 阅读 · 0 评论 -
堆排序
<br />#include <iostream>using namespace std;int heap_size;int length;//左孩子int Left(int i){ return 2*i+1;}//右孩子int Right(int i){ if(2*(i+1) <= length -1) { return 2*(i+1); } else { return原创 2010-11-17 17:09:00 · 353 阅读 · 0 评论 -
计数排序
计数排序假设n个输入中的每一个都是介于0到k之间的整数,此处k为某个整数。当k=o(n)时,计数排序的运行时间为线性的。 计数排序的基本思想就是对每一个输入元素x,确定小于x的元素个数,有了这一信息,就可以直接把x放到输出数组中的位置上。 在计数排序算法的代码中,我们假定输入是个数组A[1..n],length[A]=n。另外还需要两个数组:存放排序结果的B[1..n],以及提供临时存储的C[0..k]。原创 2010-11-23 08:00:00 · 404 阅读 · 0 评论 -
Dijkstra算法为什么权值不能是负值
Dijkstra算法当中将节点分为已求得最短路径的集合(记为S)和未确定最短路径的个集合(记为U),归入S集合的节点的最短路径及其长度不再变更,如果边上的权值允许为负值,那么有可能出现当与S内某点(记为a)以负边相连的点(记为b)确定其最短路径时,它的最短路径长度加上这条负边的权转载 2011-07-28 11:19:37 · 6790 阅读 · 1 评论