1 / 46
文档名称:

数据结构与算法2.ppt

格式:ppt   大小:625KB   页数:46
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

数据结构与算法2.ppt

上传人:lily8501 2017/12/9 文件大小:625 KB

下载得到文件列表

数据结构与算法2.ppt

文档介绍

文档介绍:Chapter 2
Algorithm Analysis
An algorithm is a clearly specified set of simple
instructions to be followed to solve a problem.
Algorithm analysis is the amount puter memory and
time needed to run a program (algorithm)
We use two approaches to determine it: performance analysis performance measurement
plexity: the amount of memory a
program needs to run pletion
plexity: the amount of time a
program needs to run pletion
plexity
ponents:
instruction space
data space (space needed for constants,simple ponent variables)
environment stack space (to save information needed to resume execution of pleted functions)
plexity
two parts:
a fixed part—include space for instructions,simple variables,fixed-ponent variables,constants
a variable part—include space ponent variables,dynamical allocated space,recursion stack
S(p)=c+Sp(instance characteristics)
plexity
2)example:
Sequential Search
public static int SequentialSearch( int [ ] a , int x )
{ int i;
for(i=0; i< &&a[i]!=x; i++) ;
if(i= = ) return –1;
return i;
}
plexity
Total data space:
12 bytes : x,i,a[i],0,-1,
each of them cost 2 bytes
S(n)=0
plexity
Recursive code to add a[0:n-1]
public static float Rsum(float[ ] a, int n)
{ if ( n>0 )
return Rsum(a, n-1) + a[n-1];
return 0;
}
plexity
Recursion stack space:
formal parameters : a (2 byte), n(2 byte)
return address(2 byte)
Depth of recursion: n+1
SRsum(n)=6(n+1)
plexity
The time taken by a program p is T(p)
T(p)=compile time+run time
pile time does not depend on the
instance characteristics
The run time is denoted by tp(instance
characteristics)
1)operation counts identify one or more key operations and determine the number of times these are performed

最近更新

2026年国开电大城市管理学形考题库100道含完整.. 38页

2025年湖北水利水电职业技术学院单招职业倾向.. 44页

2026年天津机电职业技术学院单招职业倾向性测.. 45页

2026年宪法知识竞赛试题库100道及答案(夺冠系.. 40页

2026年工贸试题-考试题库带答案(培优b卷) 42页

2026中车眉山车辆有限公司校园招聘笔试参考题.. 36页

2026年注册建筑师考试题库200道带答案(突破训.. 84页

2026年基本乐理考试试题及参考答案 29页

2026年贵州机电职业技术学院单招职业技能测试.. 44页

2026年青少年学法用法网上知识竞赛试题库含答.. 43页

2026年广西理工职业技术学院单招职业适应性测.. 45页

2026年期货网站分析笔试题库及答案1套 41页

2026年民勤县辅警招聘考试备考题库必考题 30页

项目自主成长指南建议书 6页

青春人生建议书 5页

集体组织改进建议书 5页

防疫要求诊所建议书 6页

门店美业升级建议书 6页

链路加固建议书 6页

2026年特种专业叉车考试题库及完整答案一套 28页

部门计划工作改进建议书 6页

2026年疾病控制题库【夺分金卷】 41页

运动场地升级规划建议书 6页

车架组装质量提升建议书 7页

资源节约管理建议书 6页

贫困县区经济发展建议书 4页

质量保障精益化建议书 6页

2026年网络安全知识竞赛题库附参考答案【实用.. 39页

2026年江西交通职业技术学院单招职业倾向性考.. 37页

2025年新疆考试录用公务员《公安专业科目》真.. 30页