算法设计和分析_第1页
算法设计和分析_第2页
算法设计和分析_第3页
算法设计和分析_第4页
算法设计和分析_第5页
已阅读5页,还剩47页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、烟台大学计算机学院证明正确性分析算法设计程序理解问题精确解或近似解选择数据结构算法设计策略设计算法nIsizeITIp)()()(0limnbnan032! 3! 21iixixxxxexnnenx1limabbalogbaabcccloglog)(loganabnbloglogbaaccblogloglogaabblog)/1 (logbaablog1logacbbcaloglog.5432)1ln(5432xxxxxxxxxx)1ln(10loglim)2(loglimlogabnnabnnnn00)!1(1!nnnnnnn321!nennnn112!neennnn2!nnn1211121

2、)(!nnon )2(!nn)log() !log(nnnif (expression) statement;else statement; exp1?exp2:exp3 y= x9 ? 100:200; 等价于: if (x9) y=100; else y=200;switch (expression) case 1: statement sequence; break; case 2: statement sequence; break; default: statement sequence; return-type function name(para-list) body of th

3、e function int max(int x,int y) return xy?x:y; template Type max(Type x,Type y) return xy?x:y; int i=max(1,2);double x=max(1.0,2.0);template void Make2DArray(Type* &x,int rows, int cols) x=new Type*rows; for (int i=0;irows;i+) xi=new Typecols;template void Delete2DArray(Type* &x,int rows) for (int i

4、=0;irows;i+) delete xi; delete x; x=0;templateint seqSearch(Type *a, int n, Type k) for(int i=0;in;i+) if (ai=k) return i; return -1;nIsizeavgITIpnT)()()()(pnnpnnpnpnp1321)1 (2) 1(11pnnppninpnitemplatevoid insertion_sort(Type *a, int n) Type key; / cost times for (int i = 1; i =0 & ajkey ) / c4 sum

5、of ti aj+1=aj; / c5 sum of (ti-1) j-; / c6 sum og (ti-1) aj+1=key; / c7 n-1 ) 1() 1() 1() 1() 1()(7116115114321nctctctcncncncnTniiniinii) 1() 1() 1() 1()(74321minncncncncncnT)()()(743274321nOccccnccccc1112) 1() 1(ninni112) 1(ninni)()(22) 1(2) 1(2) 1(12) 1() 1() 1()(27432765432126547654321maxnOccccncccccccncccncnncnn

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论