ALGORITHM 4.1-2
来源:互联网 发布:linux怎么进入vim 编辑:程序博客网 时间:2024/05/14 15:06
CONSOLE APPLICATION 3
analyse problem
Proposal max-subarray-problem [O(n^2)]
brute-force algorithm:
#include "stdafx.h"#include<iostream>#include<stdio.h>using namespace std;//brute-force algorithmint main(){ int n = 0, sum = 0; int q = 0, w = 0, e = 0, r = 0; cout << "this this brute force\t\n"; cout << "input the array size\n"; cin >> n; int*maxarray = new int[n]; int i = 0; cout << "please input array\n"; for (; i < n; i++) { cin >> maxarray[i]; } int tmp = 0,maxtmp=0; for (i = 0; i < n; i++) { for (w = i + 1; w < n; w++) { for (e = i; e < w; e++) { sum = 0; sum += maxarray[e]; } tmp = sum; if (tmp > maxtmp) maxtmp = tmp; } } cout << "the max subarray" << maxtmp << endl; return 0;}
But now,I can’t analyse this algorithm.
what else I also can’t figure out the divide-conquer way.
阅读全文
1 0
- ALGORITHM 4.1-2
- Algorithm 2
- ALGORITHM 4.1-5
- !!!Chapter 2 Algorithm Analysis
- PageRank Algorithm (2)
- 2-SUM algorithm
- Smarking Algorithm Contest 2
- STL algorithm -2
- Algorithm-Arrays-2
- Parallel&Distributed Algorithm-2
- Algorithm
- Algorithm
- algorithm
- algorithm
- algorithm
- algorithm
- algorithm
- Algorithm
- 剑指offer——链表反转之栈方法
- oracle中利用序列和触发器创建自增长的表
- KSGT
- ssm框架开发今天偶然发现的要注意的问题
- linux学习 tcp回绕
- ALGORITHM 4.1-2
- codeforces 439A Devu, the Singer and Churu, the Joker
- Form表单提交验证方式
- CSS选择器类型
- 键盘输入时校验文本框内容~·不定时更新内容^_^
- Makefile中的ifeq 多条件使用
- Android里面的竖虚线
- Java反射机制
- 按键精灵调用迅雷下载文件