题目:An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with ...
分类:
其他好文 时间:
2015-04-12 16:06:42
阅读次数:
107
本地应用程序利用socket(AF_INET)通信的数据在内核中的流向...
分类:
Web程序 时间:
2015-04-12 14:51:14
阅读次数:
239
堆(heap)和栈(stack)的区别先用一个比喻理解下:
使用栈:就象我们去饭馆里吃饭,只管点菜(发出申请)、付钱、和吃(使用),吃饱了就走,不必理会切菜、洗菜等准备工
作和洗碗、刷锅等扫尾工作,他的好处是快捷,但是自由度小。
使用堆:就象是自己动手做喜欢吃的菜肴,比较麻烦,但是比较符合自己的口味,而且自由度大。
1、申请方式
栈: 由...
分类:
其他好文 时间:
2015-04-12 13:27:36
阅读次数:
182
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes...
分类:
其他好文 时间:
2015-04-12 13:16:12
阅读次数:
114
#include
#include
#include
#include
using namespace std;
void size_yunsuan(string input,string &a)
{
int i=0;
int length=input.size();
stack stack1;
while(i<length)
{
//cout<<input[i]<<endl;
...
分类:
其他好文 时间:
2015-04-12 10:40:21
阅读次数:
509
题意:f[i] = min(f[i+L]~f[i+R]) + x,计算f数组。从大到小计算即可,用线段树维护一下。 1 #pragma comment(linker, "/STACK:10240000,10240000") 2 3 #include 4 #include 5 #inc...
分类:
其他好文 时间:
2015-04-12 08:02:49
阅读次数:
117
暴力的背包: 1 #pragma comment(linker, "/STACK:10240000,10240000") 2 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 ...
分类:
其他好文 时间:
2015-04-12 08:02:22
阅读次数:
97
思路:情况只可能是2种,两个人一直向一边走,或者有一个人折回来,对于后一种,枚举折回来的位置就行了。不过要注意两个方向都要处理下。 1 #pragma comment(linker, "/STACK:10240000,10240000") 2 3 #include 4 #include 5 #...
分类:
其他好文 时间:
2015-04-12 08:01:43
阅读次数:
112
题意:给定x,求有多少个10^8以内的数满足这个数乘以x以后,最高位到了最低位。设最高位的数字和剩余长度,列等式推理即可。 1 #pragma comment(linker, "/STACK:10240000,10240000") 2 3 #include 4 #include 5 #incl...
分类:
其他好文 时间:
2015-04-12 08:01:18
阅读次数:
120
题意:a[n] = ([n/1] + [n/2] + ... + [n/n]) & 1 == false,找出a数组的规律来就ok了。 1 #pragma comment(linker, "/STACK:10240000,10240000") 2 3 #include 4 #include 5...
分类:
其他好文 时间:
2015-04-12 08:00:56
阅读次数:
142