树的解释
树是ADT里面很经典的数据结构了,应用太多了,相对于链表的线性访问时间,O(n)。树的大部分操作的平均运行时间都是为O(logN)。
- 树的概念
树有几种方式定义,一种是递归,若树不为空,则一棵树是由根(root)的节点r和0个或者多个非空树组成。N个节点的树,有N-1个边。没有儿子的节点称为叶子(leaf). 对于任意节点N(i),它的深度为从根节点到N(i)的唯一路径长度。如...
分类:
其他好文 时间:
2014-07-30 01:08:02
阅读次数:
253
教训:使用邻接表的时候一定要把邻接表的结构组定义的足够大,不能仅仅等于节点的个数,因为线段的数量往往远超过节点的数量。这个题目是拓扑排序练习,提高下理解。 1 #include 2 using namespace std; 3 struct TOPO 4 { 5 int from,to,ne...
分类:
其他好文 时间:
2014-07-30 00:49:12
阅读次数:
249
本篇先介绍 下Innodb表空间,文件相关的内存数据结构。1. 数据结构Innodb的tablespace和文件的关系,是一对多的关系,先来看三个结构体1. fil_system_struct: 表示Innodb的表空间内存cache,innodb一共包括两类tablespace,即 #defi.....
分类:
数据库 时间:
2014-07-30 00:45:12
阅读次数:
260
1.和软中断相关的数据结构:softing_vec数组(kernel/softirq.c)1 static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;NR_SOFTIRQS值为10,说明内核支持...
分类:
其他好文 时间:
2014-07-30 00:31:52
阅读次数:
568
费用流即最小费用最大流先贴上粉书上的模板:struct Edge{ int from,to,cap,flow,cost; Edge(int u,int v,int c,int f,int w): from(u),to(v),cap(c),flow(f),co...
分类:
其他好文 时间:
2014-07-30 00:27:02
阅读次数:
289
先判断是否在圆内,然后用叉积判断是否在180度内。枚举判断就可以了。。。感觉是数据弱了。。#include #include #include #include #include using namespace std;const double eps=0.00000001;struct point...
分类:
其他好文 时间:
2014-07-30 00:25:52
阅读次数:
292
本题就先排序老鼠的重量,然后查找老鼠的速度的最长递增子序列,不过因为需要按原来的标号输出,故此需要使用struct把三个信息打包起来。
查找最长递增子序列使用动态规划法,基本的一维动态规划法了。
记录路径:只需要记录后继标号,就可以逐个输出了。
#include
#include
using namespace std;
const int MAX_N = 1005;...
分类:
其他好文 时间:
2014-07-29 22:08:43
阅读次数:
292
#include
#include
#include
#include
#include
using namespace std;
struct node{
int x,y,z,step;
};
int ma[51][51][51];
int A,B,C,T;
int mv[6][3] = {{1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0...
分类:
其他好文 时间:
2014-07-29 21:57:42
阅读次数:
394
1、对于题目给出的已知数据是一个开始时间和一个结束时间的题
第一反应会是将开始时间进行排序
但这样做比较麻烦
做题应该多换几个角度和思维
将这类题按结束时间进行排序会简单的多
2、结构体
struct move //struct是结构体函数
{
int a; //结构体成员
dou...
分类:
其他好文 时间:
2014-07-29 21:51:32
阅读次数:
257
#include #include #include #include using namespace std;int a,b,c,s,e;int v[101][101];struct node{ int x,y,ans;}q[100001],t,f;void FILI(int xx,int ...
分类:
其他好文 时间:
2014-07-29 21:29:12
阅读次数:
231