摘要: 线段树(Segment Tree)也称区间树(Interval Tree)、范围树(Range Tree),是一种用于区间信息的维护与查询的特殊数据结构。线段树使用分治思想,将连续区间递归分解成若干小区间,在处理范围修改查询等操作时能够通过整合小区间的信息减少运算量从而实现快速修改与查询。 线段树的 阅读全文
posted @ 2020-06-13 00:55 LowBee 阅读(390) 评论(0) 推荐(0) 编辑
摘要: 1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one 阅读全文
posted @ 2019-02-26 19:57 LowBee 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (un 阅读全文
posted @ 2019-02-26 18:13 LowBee 阅读(246) 评论(0) 推荐(0) 编辑
摘要: /* Dijkstra 算法求单源最短路径 将所有结点分为两个集合 S D ,S为未访问的结点集合,D为已访问的集合 每次从集合D中找到一条到达集合S中结点的最短路径,将该点加入到D集合,并更新加入该点后的最短路径 */ #include #include #include using namespace std; const int MAX=1E9; const int... 阅读全文
posted @ 2018-05-17 11:04 LowBee 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 邻接矩阵模板类 图的邻接表 阅读全文
posted @ 2018-05-16 15:28 LowBee 阅读(754) 评论(0) 推荐(0) 编辑
摘要: 照着书上给的代码段改了一上午BUG,最后发现是书上代码有问题。。。 阅读全文
posted @ 2018-05-12 14:26 LowBee 阅读(346) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; template class MinHeap{ private: T *heapArray; int CurrentSize; int MaxSize; void swap(int pos_x,int pos_y) //交换 { T temp; ... 阅读全文
posted @ 2018-05-11 15:30 LowBee 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 代码是根据之前的二叉树模板修改来的,删去了非递归遍历,加入二叉搜索树的搜索、插入和删除,实现方法在73~153行 阅读全文
posted @ 2018-05-11 12:52 LowBee 阅读(1176) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;template <class T>class CompleteBinaryTree{ //完全二叉树,所有结点从0~n-1编号 //对于结点i,它的左右子树分别位于2i+1和2i+2,它的父结点为[(i-1)/2] //除 阅读全文
posted @ 2018-05-11 12:35 LowBee 阅读(150) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; template class BinaryTree; template class BinaryTreeNode { friend class BinaryTree; private: T data; //二叉树数据域 BinaryTreeNode *leftchild; ... 阅读全文
posted @ 2018-05-11 07:58 LowBee 阅读(251) 评论(0) 推荐(0) 编辑