上一页 1 ··· 203 204 205 206 207 208 209 210 211 ··· 455 下一页
求递归算法时间复杂度:递归树 递归算法时间复杂度的计算方程式一个递归方程: 在引入递归树之前可以考虑一个例子:T(n) = 2T(n/2) + n2 迭代2次可以得:T(n) = n2+ 2(2T(n/4) + (n/2)2) 还可以继续迭代,将其完全展开可得:T(n) = n2+ 2((n/2)2+ 2((n/22)2+ 2((n/23)2+ 2((n/24)2+…+2((n/2i)2+ 2T(n/2i + 1)))…))))……(1) 而当n/2i+1== 1时,迭代结束。 将(1)式小括号展开,可得:T(n) = n2+ 2(n/2)2+ 22(n/22)2+ … + 2i(n/2i)2 Read More
posted @ 2013-05-14 20:53 javawebsoa Views(362) Comments(0) Diggs(0)
//// 二叉树线索化的头文件:BinaryThreadTree.h#ifndef B_T_T_H#define B_T_T_H#include <stdio.h>//// 返回OK表示正常返回#define OK 1//// 返回ERROR,表示异常返回#define ERROR 0//// 返回OVERFLOW,表示内存溢出#define OVERFLOW -1//// 线索结构体typedef enum { Link = 0, // 指针 Thread = 1 // 线索}PointerTag;//// 树结点的数据的类型typedef char ElemType; //// Read More
posted @ 2013-05-14 20:52 javawebsoa Views(457) Comments(0) Diggs(0)
一道比较简单的线段树,但是还是wa了两遍才ac,线段树写得还是不够熟练。线段树的模板型挺强的,感觉不容易出现什么bug,就算出现了也都是笔误之类的。#include<stdio.h>#include<string.h>#define N 200005struct node{ int x,y,max;}a[N*3];int Max(int x,int y){ return x>y?x:y;}void CreatTree(int t,int x,int y){ a[t].x=x; a[t].y=y; a[t].max=0; if(x==y) ret... Read More
posted @ 2013-05-14 20:50 javawebsoa Views(173) Comments(0) Diggs(0)
explain SQL语句:查询消耗的时间 select version():查看mysql版本 show profiles:分析sql性能 set profiling=1:打开profiles功能,默认是关闭的 show profile for query x(x为query_id):根据query_id 查看某个查询的详细时间耗费 show profile block io,cpu,memory,swaps,source,context switches for query x(x为query_id):查看占用cpu、 io等信息 1.清除缓存reset query cache ... Read More
posted @ 2013-05-14 20:48 javawebsoa Views(142) Comments(0) Diggs(0)
一、fcntl函数功能:操纵文件描述符,改变已打开的文件的属性 int fcntl(int fd, int cmd, ... /* arg */ ); cmd的取值可以如下:复制文件描述符 F_DUPFD (long) 设置/获取文件描述符标志 F_GETFD (void) F_SETFD (long) 设置/获取文件状态标志 F_GETFL (void) F_SETFL (long) 获取/设置文件锁 F_GETLK F_SETLK,F_SETLKW 其中复制文件描述符可参见《linux系统编程之文件与I/O(五):打开文件的内核结构file和重定向》,文件描述符的标志只有一个即FD_C.. Read More
posted @ 2013-05-14 20:46 javawebsoa Views(1223) Comments(0) Diggs(1)
在使用RCFileInputFormat时可以设置需要读取的列的序号:/***Setsreadcolumns'ids(startfromzero)forRCFile'sReader.Onceacolumn*isincludedinthelist,RCFile'sreaderwillnotskipitsvalue.**/publicstaticvoidsetReadColumnIDs(Configurationconf,ArrayList<Integer>ids){Stringid=toReadColumnIDString(ids);setReadColumn Read More
posted @ 2013-05-14 20:44 javawebsoa Views(275) Comments(0) Diggs(0)
ctex自带的winedt很不爽,毅然决定更换免费又美观的texmaker很轻松地安装了ctex,但是texmaker编辑的tex中如果出现中文总是不对,要么是编译错误,要么就是显示为乱码,有很多人说要把文档保存的编码选为utf-8没用,除了在texmaker中选择我还用其它的工具转换,都不行,后来无意之间将编码换成了gbk,一切都OK,害的我郁闷了好几天。 Read More
posted @ 2013-05-14 20:42 javawebsoa Views(323) Comments(0) Diggs(0)
1,dao和service对应 一般情况下,Hibernate DAO只操作一个POJO对象,因此一个DAO对应一个POJO对象。 Service层是为了处理包含多个POJO对象(即对多个表的数据操作)时,进行事务管理(声明式事务管理)。Service层(其接口的实现类)被注入多个DAO对象,以完成其数据操作。2, Service之有无 这一点我的看法未必正确,我的脑海现在有两种构建业务层的模式: 模式1是Service + DAO,即DAO中只做CRUD及类似的简单操作(称之为功能点,不包含业务逻辑),Service中通过调用一个或多个DAO中的功能点来组合成为业务逻辑.Service的.. Read More
posted @ 2013-05-14 20:40 javawebsoa Views(548) Comments(0) Diggs(0)
#include <stdio.h>#include <stdlib.h>#include <math.h>float distance(int a, int b, int c, int d);int main(int argc, char *argv[]){ int a; int b; int c; int d; printf("Please enter the first coordinate points x:"); //输入第一个点 scanf("%d %d", &a, &b); printf( Read More
posted @ 2013-05-14 20:38 javawebsoa Views(350) Comments(0) Diggs(0)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=15&problem=1332&mosmsg=Submission+received+with+ID+11760306 思路很简单,写博客目的是记住find、substr的用法#include<iostream>#include<set>using namespace std;int main(){ set<string> s; Read More
posted @ 2013-05-14 20:36 javawebsoa Views(165) Comments(0) Diggs(0)
上一页 1 ··· 203 204 205 206 207 208 209 210 211 ··· 455 下一页