随笔分类 -  其他 数据结构

摘要:并查集 1. 并查集是什么 并查集是一种用来管理元素分组情况的数据结构。并查集可以高效地进行如下操作。不过需要注意并查集虽然可以进行合并操作,但是无法进行分割操作。 查询元素a和元素b是否属于同一组。 合并元素a和元素b所在的组。 查询元素a和元素b是否属于同一组。 合并元素a和元素b所在的组。 2 阅读全文
posted @ 2017-02-15 17:18 douzujun 阅读(5308) 评论(2) 推荐(1) 编辑
摘要:总结:通常最短路(最优解)问题会考虑用BFS来进行求解 阅读全文
posted @ 2017-02-03 19:26 douzujun 阅读(654) 评论(0) 推荐(0) 编辑
摘要:https://github.com/douzujun/MyMapView 主要算法讲解: 1. 计算最短路径(dijkstra算法) Step1: (1)找到最短路径已经确定的顶点,从它已经确定的顶点,从它除法更新相邻顶点的最短距离。 (2)此后不需要再关心1中的“最短距离已经确定的顶点”。 (3 阅读全文
posted @ 2017-01-11 10:41 douzujun 阅读(10204) 评论(0) 推荐(3) 编辑
摘要:1 //MainWidget.h 2 3 #ifndef MAINWINDOW_H 4 #define MAINWINDOW_H 5 6 #include 7 #include "mapwidget.h" 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #i... 阅读全文
posted @ 2017-01-08 20:17 douzujun 阅读(2629) 评论(3) 推荐(1) 编辑
摘要:1. 冒泡排序(平均时间复杂度O(n^2), 辅助空间O(1), 稳定排序) 主要思想: 两两比较相邻记录的关键字值,如果是反序则交换,直到没有反序记录为止。 2. 插入排序 (平均时间复杂度O(n^2),辅助空间O(1),稳定排序) 基本思想:依次把待排序序列中的每一个记录插入到一个已经排序好的序 阅读全文
posted @ 2016-12-13 17:06 douzujun 阅读(418) 评论(0) 推荐(0) 编辑
摘要:1 /* 2 10 10 3 #.######.# 4 ......#..# 5 .#.##.##.# 6 .#........ 7 ##.##.#### 8 ....#....# 9 .#######.# 10 ....#..... 11 .####.###. 12 ....#....# 13 0 1 14 9 8 15 */ 16 #defi... 阅读全文
posted @ 2016-11-18 16:52 douzujun 阅读(520) 评论(0) 推荐(0) 编辑
摘要:1 //最优二叉树 2 #include 3 #include 4 using namespace std; 5 6 //定义结点类型 7 //【weight | lchid | rchild | parent】 8 //为了判定一个结点是否已加入到要建立的哈夫曼树中 9 //可通过parent域的值来确定. 10 //初始时parent = -1,... 阅读全文
posted @ 2016-11-01 22:36 douzujun 阅读(928) 评论(0) 推荐(0) 编辑
摘要:1 //最优二叉树 2 #include 3 #include 4 using namespace std; 5 6 //定义结点类型 7 //【weight | lchid | rchild | parent】 8 //为了判定一个结点是否已加入到要建立的哈夫曼树中 9 //可通过parent域的值来确定. 10 //初始时parent = -1,... 阅读全文
posted @ 2016-11-01 16:31 douzujun 阅读(643) 评论(0) 推荐(0) 编辑
摘要:1 //测试数据 2 //1 2 4 7 -1 -1 -1 5 -1 -1 3 -1 6 -1 -1 3 //1 2 4 11 -1 22 -1 -1 -1 5 -1 -1 3 6 -1 -1 7 -1 -1 4 5 6 #include 7 #include 8 using namespace std; 9 10 template 11 st... 阅读全文
posted @ 2016-10-31 22:39 douzujun 阅读(271) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 using namespace std; 4 5 template 6 struct BinaryNode 7 { 8 T element; 9 BinaryNode *left; 10 BinaryNode *right; 11 12 BinaryNode(cons... 阅读全文
posted @ 2016-10-29 21:31 douzujun 阅读(239) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 using namespace std; 4 5 template 6 struct BinaryNode 7 { 8 T element; 9 BinaryNode *left; 10 BinaryNode *right; 11 12 BinaryNode(cons... 阅读全文
posted @ 2016-10-23 16:09 douzujun 阅读(495) 评论(0) 推荐(0) 编辑
摘要:http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html 阅读全文
posted @ 2016-10-12 10:07 douzujun 阅读(155) 评论(0) 推荐(0) 编辑
摘要:(更新过后的代码效果) 阅读全文
posted @ 2016-10-08 16:34 douzujun 阅读(2216) 评论(2) 推荐(0) 编辑
摘要:1 /* 2 8 6 3 1 1 1 1 1 1 1 1 4 1 0 0 1 0 0 1 1 5 1 1 0 0 0 0 0 1 6 1 0 0 1 0 1 0 1 7 1 0 0 0 0 0 0 1 8 1 1 1 1 1 1 1 1 9 */ 10 #include <iostream> /// 阅读全文
posted @ 2016-10-07 22:44 douzujun 阅读(356) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 11 void welcome(); //欢迎模块 12 void play_mp3... 阅读全文
posted @ 2016-09-30 00:45 douzujun 阅读(346) 评论(0) 推荐(0) 编辑
摘要:1 #ifndef VECTOR_H 2 #define VECTOR_H 3 4 #include 5 6 template 7 class Vector 8 { 9 private: 10 int theSize; //实际数据大小 11 int theCapacity; ... 阅读全文
posted @ 2016-09-22 22:18 douzujun 阅读(809) 评论(2) 推荐(0) 编辑
摘要:1 //SLinkList.h 2 3 #ifndef _SLINK_LIST_ 4 #define _SLINK_LIST_ 5 6 template 7 class SLinkList 8 { 9 public: 10 SLinkList(int maxz = 100); 11 ~SLinkList(); 12 void ... 阅读全文
posted @ 2016-09-11 22:13 douzujun 阅读(510) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示