渴死的火烈鸟
standalone · 共 356 篇文章
code snippet
char temp[3]; char temp2[3]; int a[100]; void split(int m, int n, int a[], int index){ if(m!=0){ a[index]=m; if(index-1>=0 && a[index]<a[index-1]) return; index++; }else m=1; for(int i=m;i<=n-1;i++){ split(i,n-i,a,index); a[index]=i; a[index+1]=n-i; if(a[index]<=a[index+1]){ for(int j=0;j<=index+1;…
2010-09-27 08:31 · c++ · 评论(0)
调整堆的算法
Begin adjustHeap(A[], i) // Heapify takes in our heap and index of current root node of subtree to be heapified { left=leftChild(); right=rightChild(); largest=i; if left<=A.heap-size AND A[left]>A[i] { largest=left; } if right<=A.heap-size AND A[right]>A[i] { largest=right; } if largest NOT EQUAL …
2010-09-25 10:34 · c++ · 评论(0)
multiset usage as heap
Middle number There is a sequence of integers, we have two operations now 1 add a: means add an integer a to the end of the sequence, forms a N+1 long sequence. 2 mid : Output the current sequence's middle numbera sequence's middle number is the middle position of the sequence when it's sorted by i…
2010-09-24 21:37 · c++ · 评论(0)
虚函数表又是怎样实现的?
每个含有虚函数的类有一张虚函数表(vtbl),表中每一项指向一个虚函数的地址,实现上是一个函数指针的数组。 虚函数表既有继承性又有多态性。每个派生类的vtbl继承了它各个基类的vtbl,如果基类vtbl中包含某一项,则其派生类的vtbl中也将包含同样的一项,但是两项的值可能不同。如果派生类覆盖(override)了该项对应的虚函数,则派生类vtbl的该项指向重载后的虚函数,没有重载的话,则沿用基类的值。 在类对象的内存布局中,首先是该类的vtbl指针,然后才是对象数据。在通过对象指针调用一个虚函数时,编译器生成的代码将先获取对象类的vtbl指针,然后调用vtbl中对应的项。对于通过对象指针调…
2010-09-20 22:01 · c++ · 评论(0)
记一次面试
今天参加了一个phone interview,有几道题自己还记着。 1. c++析构函数为啥是虚函数。 2. 四个cast。 3. 类初始化列表。编译器为什么要按照声明中的顺序初始化? 4. 一个空类,编译器帮你实现了哪些default的函数。 4. IQ题。假设三个事件A,B,C,给你两枚硬币,如果根据扔硬币的结果得到独立概率的一件事情。
2010-09-20 15:10 · algorithm · 评论(0)
正整数分解算法
问题:将以正整数n表示成一系列正整数之和. n=n1+n2+n3+...+nk (n1>=n2>=n3>=nk>=1, k>=1)这就是正整数n的一个划分,正整数n不同的划分个数称为正整数n的划分数, 记作p(n)例如:6 有如下11种划分则p(6)=116;5+1;4+2, 4+1+1;3+3, 3+2+1, 3+1+1+1;2+2+2, 2+2+1+1, 2+1+1+1+1;1+1+1+1+1+1;则求任意正整数的划分数p(n). 1. c改编的 class Int { private int n; private int[] a; public int cnt; public Int(…
2010-09-19 16:56 · c++ · 评论(0)
Reading for ParNew (promotion failed) and (concurrent mode failure)
http://java-monitor.com/forum/showthread.php?t=645 Dear All, If you are struggling to understand the messages ParNew (promotion failed) and (concurrent mode failure), you might want to bone up on memory management and garbage collector internals. ParNew (promotion failed): This means that your old …
2010-09-19 11:22 · java · 评论(0)
Reading for ParNew (promotion failed) and (concurrent mode failure)
http://java-monitor.com/forum/showthread.php?t=645 Dear All, If you are struggling to understand the messages ParNew (promotion failed) and (concurrent mode failure), you might want to bone up on memory management and garbage collector internals. ParNew (promotion failed): This means that your old …
2010-09-19 11:19 · java · 评论(0)
java jvm GC 参数设置
1: heap size a: -Xmx 指定jvm的最大heap大小,如:-Xmx2g b: -Xms 指定jvm的最小heap大小,如:-Xms1g c: -Xmn 指定jvm中New Generation的大小,如:-Xmn256m d: -XX:PermSize 指定jvm中Perm Generation的最小值,如:-XX:PermSize=32m e: -XX:MaxPermSize 指定Perm Generation的最大值,如:-XX:MaxPermSize=64m f: -Xss 指定线程桟大小,如:-Xss128k g: -XX:NewRatio 指定jvm中Old Ge…
2010-09-19 10:54 · java · 评论(0)
异或运算法则
1. a ^ b = b ^ a 2. a ^ b ^ c = a ^ (b ^ c) = (a ^ b) ^ c; 3. d = a ^ b ^ c 可以推出 a = d ^ b ^ c. 4. a ^ b ^ a = b.
2010-09-14 09:47 · c++ · 评论(0)
常量字符串为什么位于静态存储区
http://hi.baidu.com/%D0%C7%BB%F0%D3%C4%C0%B6/blog/item/410174384e529ffbb211c71c.html
2010-09-13 22:41 · c++ · 评论(0)
云计算 定义
【云计算】概念是由Google提出的,这是一个美丽的网络应用模式。狭义云计算是指IT基础设施的交付和使用模式,指通过网络以按需、易扩展的方式获得所需的资源;广义云计算是指服务的交付和使用模式,指通过网络以按需、易扩展的方式获得所需的服务。这种服务可以是IT和软件、互联网相关的,也可以是任意其他的服务,它具有超大规模、虚拟化、可靠安全等独特功效;“云计算”图书版本也很多,都从理论和实践上介绍了云计算的特性与功用。 (1) 超大规模 具有相当的规模,Google云计算已经拥有100多万台服务器, Amazon、IBM、微软、Yahoo等的“云”均拥有几十万台服务器。企业私有云一般拥有数百上千台服…
2010-09-10 17:26 · cloud · 评论(0)
How to generate permutations
The following algorithm generates the next permutation lexicographically after a given permutation. It changes the given permutation in-place. Find the largest index k such that a [ k ] < a [ k + 1] . If no such index exists, the permutation is the last permutation. Find the largest index l such th…
2010-09-07 23:10 · algorithm · 评论(0)
generate combinations
http://compprog.wordpress.com/2007/10/17/generating-combinations-1/ #include <iostream> #include <vector> using namespace std; void print(vector<char> chars, char array[], int k){ for(int j=0;j<k;j++) cout<<chars.at(array[j]); cout<<endl; } bool next(char array[], int n, int k){ int i=k-1; while(i>…
2010-09-07 22:52 · java · 评论(0)