
树
soundwave_
Talk is cheap. Show me the code.
展开
-
看懂二叉树的三种遍历
二叉树的遍历分为以下三种:先序遍历:遍历顺序规则为【根左右】中序遍历:遍历顺序规则为【左根右】后序遍历:遍历顺序规则为【左右根】什么是【根左右】?就是先遍历根,再遍历左孩子,最后遍历右孩子;举个例子,看下图(图从网上找的):先序遍历:ABCDEFGHK中序遍历:BDCAEHGKF后序遍历:DCBHKGFEA以中序遍历为例:中序遍历的规则是【左根右】,原创 2016-11-10 21:08:09 · 159994 阅读 · 38 评论 -
[线段树]poj3667 Hotel(区间合并、更新、延迟/懒惰标记
HotelTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 16089 Accepted: 6998DescriptionThe cows are journeying north to Thunder Bay in Canada to gain cul原创 2016-08-17 19:02:47 · 302 阅读 · 0 评论 -
[线段树]hdu1698 Just a Hook(区间更新、延迟标记
Just a HookTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28346 Accepted Submission(s): 14047Problem DescriptionIn the game原创 2016-08-15 22:39:57 · 344 阅读 · 0 评论 -
[模板]线段树的建树、查询、单点更新、区间更新
此线段树以求区间最小值为例,求区间和只需适当更改pushup()函数即可建树int arr[N];int SetTree[N*4];int pushup(int root){ return min(SetTree[root<<1], SetTree[root<<1|1]);}void build(int root, int left, int right){原创 2016-08-15 22:00:40 · 296 阅读 · 0 评论 -
[模板]Trie树
#include #include #include using namespace std;const int N = 26;struct Trie{ int num; bool terminal; struct Trie *next[N]; Trie() { memset(next, NULL, sizeof(next));原创 2016-07-30 08:45:39 · 239 阅读 · 0 评论