Solutions_to_Introduction_to_Algorithm_3nd_Exercise_4
来源:互联网 发布:2016最新网络流行词汇 编辑:程序博客网 时间:2024/06/06 02:48
4.1-1 What does FIND-MAXIMUM-SUBARRAY return when all elements of A are negative?
The biggest negative one.
4.1-2 Write pseudocode for the brute-force method of solving the maximum-subarray problem. Your procedure should run inΘ(n^2);
The biggest negative one.
4.1-2 Write pseudocode for the brute-force method of solving the maximum-subarray problem. Your procedure should run inΘ(n^2);
typedef struct{int max_left;int max_right;int max;}maxinfo;maxinfo bf_MaxSubArray(int *a,int n){maxinfo max;max.max_left= 0;max.max_right= 0;max.max= MIN_INT;int tmp=0;for(int i=0;i<n;i++){for(int j=i;j<n;j++){tmp += a[j];if(tmp > max.max){max.max = tmp;max.max_left = i;max.max_right = j;}}tmp = 0;}return max;}
- Solutions_to_Introduction_to_Algorithm_3nd_Exercise_4
- 九度OJ 1089: 树查找
- 大家帮忙解决下问题哈
- 一起来学POSIX thread 之 线程状态
- Android使用Application总结
- operamasks 2013 license 过期
- Solutions_to_Introduction_to_Algorithm_3nd_Exercise_4
- 【经验总结2】httplib2 下载 gzip数据
- 如何查错
- 如何用CodeSmith减少代码重复编写
- 数独的求解算法 回溯
- PyCharm 注册码
- Hibernate 异常org.hibernate.LazyInitializationException: could not initialize proxy - no Session
- poj - 1061 - 青蛙的约会(扩展欧几里德)
- 黑马程序员--继承