当前位置: 首页 > news >正文

wordpress小米论坛主题江苏seo哪家好

wordpress小米论坛主题,江苏seo哪家好,北湖区网站建设哪家好,贵阳网站建设制作公司【0】README1)本文旨在review 算法分析的几个算法问题 附带源码#xff1b;【1】最大子序列和问题的解#xff08;两种解法——分治法联机算法#xff08;推荐#xff09;#xff09;【1.1】分治法1#xff09;intro#xff1a;其思想是把问题分成两个大致相等的子问题【1】最大子序列和问题的解两种解法——分治法联机算法推荐【1.1】分治法1intro其思想是把问题分成两个大致相等的子问题然后递归地对它们进行求解这是“分”部分“治”阶段 将两个子问题的 解合并到一起并可能再做些少量的附加工作最后得到整个问题的解 2算法idea 描述在我们的例子中求最大子序列和的问题最大子序列和可能出现在三个地方——或者整个出现在输入数据的左半部、或者整个出现在右半部、或者跨越输入数据的中部从而占据左右两半部分3如何求其解呢  前两种情况可以递归求解第3种情况的最大和可以通过求出前半部分的最大和包含前半部分的最后一个元素以及 后半部分的最大 和包含后半部分的第一个元素而得到。然后将这两个和加在一起4算法流程演示和源码如下#includestdio.h#define ElementType intint max3(int i, int j, int k) {if(i j){i j;}if(i k){i k;}return i; }// compute the maximum sum of sebsequence. // 3 in mxSubSum3 means 3 possibilities. int maxSubSum3(int A[], int left, int right) {int onlyLeftSum, onlyRightSum; // just only left or right sum without center.int centerLeftSum, centerRightSum; // the 3rd is passing center.int tempSum;int center, i;if(leftright){if(A[left] 0){return A[left];}else{return 0;}}center (leftright)/2; onlyLeftSum maxSubSum3(A, left, center);onlyRightSum maxSubSum3(A, center 1, right);centerLeftSum 0; tempSum 0; for(icenter; ileft; i--) { tempSum A[i];if(tempSum centerLeftSum){centerLeftSum tempSum;}}centerRightSum 0;tempSum 0;for(icenter1; iright; i) { tempSum A[i];if(tempSum centerRightSum){centerRightSum tempSum;}}printf(onlyLeftSum%d, onlyRightSum%d, centerLeftSum centerRightSum%d \n, onlyLeftSum, onlyRightSum, centerLeftSum centerRightSum);return max3(onlyLeftSum, onlyRightSum, centerLeftSum centerRightSum); } int main() {int N 8, maxSum 0; ElementType A[] {4, -3, 5, -2, -1, 2, 6, -2}; maxSum maxSubSum3(A, 0, N-1); printf(the maximum sum of array {4, -3, 5, -2, -1, 2, 6, -2} is: %d \n, maxSum); }【1.2】联机算法1intro在任意时刻算法对要操作的数据只需要读入一次一旦被读入处理它就不再需要被记忆了。而在处理过程中算法对已读入的数据给出了正确的答案具有这种特性的算法叫联机算法2利用 联机算法求最大子序列和问题的解源码如下比 分治法效率高 #includestdio.h#define ElementType int// 联机算法计算最大子序列和问题. int maxSubSequenceSum(int A[], int N) {int thisSum0, maxSum0;int j; for(j 0; j N; j) {thisSum A[j];if(thisSum maxSum){maxSum thisSum;}else if(thisSum 0){thisSum 0;}}return maxSum; }int main() {int N 8, maxSum 0; ElementType A[] {4, -3, 5, -2, -1, 2, 6, -2}; maxSum maxSubSequenceSum(A, N);printf(the maximum sum of array {4, -3, 5, -2, -1, 2, 6, -2} is %d \n, maxSum); return 0; }【2】运行时间中的对数【2.1】荔枝1——二分查找 #includestdio.h#define ElementType int #define NOTFOUND -1/* 二分查找A[]升序排列 */ int binarySearch(ElementType A[], ElementType x, int N) {int low, mid, high;low 0;high N - 1;while (low high){mid (low high) / 2;if(A[mid] x){low mid 1;}else if(A[mid] x){high mid - 1; }else {return mid;}}return NOTFOUND; } main() {int A[]{4, 5, 67, 67, 109, 876};int N6, x109; printf(\narray[] {4, 5, 67, 67, 109, 876});printf(\nthe position whose value equals to %d is %4d\n, x, binarySearch(A, x, N)); }【2.1】荔枝2——计算最大公因数欧几里得 算法 #includestdio.h#define ElementType int #define NOTFOUND -1/* 求两个数的最大公因数greatest common divisor */ int gcd(int M, int N) {int rem;printf(remainder sequence: );while (N 0){rem M % N;M N;N rem;printf(%4d, rem);}return M; }main() {int N 1989, M 1590; int gcd_value;printf(\t\t\t test for greatest common divisor \n\n); gcd_value gcd(M, N);printf(\nthe greatest common divisor between %4d and %4d is %4d\n, M, N, gcd_value);}【2.1】荔枝3——高效率的幂运算 1减少乘法次数如 X^62 只用到了9次乘法X^3(X^2)*X , X^7(X^3)^2*X , X^15(X^7)^2*X , X^31(X^15)^2*X , X^62(X^31)^22 2 2 2 1 9次 #includestdio.hint isEven(int N) {return N % 2 0 ? 1 : 0; }int pow(int x, int N) {if(N 0){return 1;}else if(N 1){return x;}else if(isEven(N)) /* if(x) if(N!0) */{return pow(x * x, N / 2);}else{return pow(x * x, N / 2) * x;} }void main() {int x 2, N 7;long pow_ pow(x,N);printf(\t\t\t test for computing pow \n);printf(\t\t\t result of %d^%d is %-6d\n, x, N, pow_); }
http://www.sadfv.cn/news/226356/

相关文章:

  • 建一个商城网站多少钱重庆公司大学派斯学院
  • 怎样建立自己的公众号seo关键词优化公司
  • 2019年云南建设银行招聘网站网站设置价格错误不愿意发货
  • 购物网站 wordpress 英文模板wordpress怎么看展现量
  • 网站建设怎么添加图片上去酒吧网站模板
  • 番禺营销型网站建设网站的色彩搭配
  • 温州个人网站建设学生个人博客网站模板
  • 公司网站服务商处理营销型网站建设策划的几个误区
  • wordpress建站 东莞网站建设测评报告
  • 做wd网站实训报告总结seo软件排行榜前十名
  • 新乡专业网站建设公司网站建设模式有哪些内容
  • 做网站有限公司做网站编辑需要经验吗
  • 清河哪里做网站最新网站建设的模板
  • 厦门网站改版做百度网站那家好
  • 网站开发运营维护方案建议烟台论坛
  • 焦作音响网站建设做网站仓库报表系统
  • 胶南做网站查询百度关键词排名
  • 高平企业网站焦作网站建设哪家权威
  • 商城网站项目策划书怎么创建公众号赚钱
  • 网站建设行业发展新手如何写公众号文章
  • 西安响应式网站建设wordpress文件大小
  • 伊春市建设局网站济南百度推广优化
  • 商派商城网站建设九江网站建设求职简历
  • 网站建设开发哪家好百度官网登录入口
  • 企业oa系统免费英文网站seo方案
  • 设计业务网站南通城市建设集团网站
  • 单页营销网站模板无锡定制网站
  • 金融类网站建设网站 锚点链接怎么做
  • 查找网站建设历史记录软考培训机构哪家好一点
  • 外贸假发网站公司网址一般是什么