![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Wenbin_Yang
这个作者很懒,什么都没留下…
展开
-
(图)最小生成树(普利姆算法)
1.点集合(根据第一个点找出下一个点) 2.最小边集合(从待选边中找出最小边) 3.待选边集合 //普利姆算法 void Cmap::primTree(int nodeIndex) { int value = 0; int edgeCount = 0; //最小边数目 vector<int> nodeVec;//存放结点 vector<Edge> edgeVec原创 2017-05-21 13:25:59 · 552 阅读 · 0 评论 -
图(二叉树)邻接矩阵(数组描述)
//结点类 //.h #ifndef NODE #define NODEclass node { public: node(char data=0); char m_cData; //顶点数据 bool m_bIsVisited; //顶点是否被访问 };#endif //.cpp #include"node.h"node::node(char data) { m_c原创 2017-05-20 15:15:51 · 2804 阅读 · 1 评论 -
二叉树(链表)
搜索 删除 前序 后续遍历都在Node 这类中实现 然后 在树中去调用(注意递归函数的使用???) Node.h#include<iostream> using namespace std; template<class T> class Node { public: int index; int data; Node *pLChild; Node *pRChil原创 2017-05-19 10:37:28 · 337 阅读 · 0 评论 -
数据结构之栈(链表栈)
#include"chainNode.h" #include"exceptions.h" #include"stack.h" template<class T> class linkedStack:public stack<T> { public: linkedStack(int initialCapacity = 10) { stackTop = NULL;原创 2017-05-09 19:28:05 · 299 阅读 · 0 评论 -
数据结构之栈篇
栈是一种特殊的线性表 其插入(也称为入栈和压栈)和删除(出栈和弹栈)操作都在痛一端进行,一端为栈顶 一端为栈底 #include"stack.h" #include"exception.h" #include<algorithm> #include<sstream> using namespace std;template<class T>class arrayStack :public stack原创 2017-05-09 13:49:34 · 359 阅读 · 0 评论 -
二叉树数组描述
#include<iostream> using namespace std; template <class T>class Tree { public: Tree(int size,T*pRoot);//创建树 ~Tree();//销毁 T *searchNode(int nodeIndex);//根据索引寻找结点 bool AddNode(int nodeInd原创 2017-05-17 09:54:54 · 615 阅读 · 0 评论 -
矩阵类
将矩阵matrix用一个一维数组element储存(涉及了很多运算符重载的方法) #include"expection.h" using namespace std; template <class T> class matrix { friend ostream& operator<<(ostream &, const matrix<T>&); public: matrix(int原创 2017-05-08 16:11:43 · 318 阅读 · 0 评论 -
链表基数排序问题
基数排序 即用基数10 把十进制数928分解为数字9,2,8,把3275分解为3,2,7,5。 1 利用箱子排序根据最低位数字即个位数字进行排序 2利用箱子排序 对1 的结果按十位数字进行排序 3利用箱子排序 对2 的结果按百位数字进行排序 (325=3*100+2*10+5*1 , 5=325%100,2=(325%100)/10,3=325/100)void numSort(chain原创 2017-05-07 15:56:05 · 500 阅读 · 0 评论 -
链表箱子排序问题
箱子排序 1,逐个删除输入链表的节点,把删除节点分配到相应的箱子里 2,把每个箱子中的链表收集并连接起来,使其成为一个有序链表 (即连续删除链表首元素,并将其插入某个箱子的链表首位,然后从最后一个箱子开始,逐个删除每个箱子的首元素,并将其插入一个链表为空的链表首位)void binSort(chain<studentRecord> &thechain, int range) {原创 2017-05-07 15:46:25 · 854 阅读 · 0 评论 -
矩阵运算
矩阵转置void transpose(int **a, int rows, int column) { for (int i = 0; i < rows; i++) { for (int j = i+1; j < column; j++) { swap(a[i][j],a[j][i]); } } }矩阵相原创 2017-05-07 21:23:57 · 344 阅读 · 0 评论 -
线性表篇之顺序表
/* 1创建一个线性表 2撤销一个线性表 3确定线性表是否为空 4确定线性表的长度 5按一个给定的索引查找一个元素 6按一个给定的元素查找其索引 7按一个给定的索引删除一个元素 8按一个给定的索引插入一个元素 9从左至右顺序输出线性表元素 */ #ifndef arrayList_ #define arrayList_#include<sstream> #include<string> #inclu原创 2017-05-01 14:39:27 · 532 阅读 · 0 评论 -
线性表之链表
#include<iostream> #include<sstream> #include<string> #include"linearList.h" #include"chainNode.h" #include"exception.h" using namespace std; template<class T> class chain :public linearList < T > { pu原创 2017-05-04 19:18:24 · 300 阅读 · 0 评论 -
队列(数组描述)
队列一个先进先出的线性表 (环形队列 逆时针)#include<iostream> #include"queue.h" using namespace std; template<class T>class arrayQueue :public queue<T> { public: arrayQueue(int initialCapacity = 10); ~arrayQueue(原创 2017-05-14 19:38:25 · 277 阅读 · 0 评论 -
栈应用 一(括号匹配)
#include <iostream> #include "linkedStack.h" #include "exceptions.h"using namespace std; //括号匹配 void printMatchedPairs(string exper) { linkedStack<int> s; int length = exper.size(); //字符串的长度原创 2017-05-10 21:24:22 · 214 阅读 · 0 评论 -
(图)最小生成树(克鲁斯卡尔算法)
第一步取出所有边 第二步从所有边中取出组成最小生成树的 1.找到算法结束条件 2.从边集合中取出最小边 3.找出最小边连接到的点 4.找出点所在的点集合 5.根据所在集合的不同做出不同的处理//克鲁斯卡尔算法生成树 void Cmap::kruskalTree() { int value = 0; int edgeCount = 0;//计数(最小边集合中边的数目)原创 2017-05-21 17:33:22 · 631 阅读 · 0 评论