算法与设计算法分析基础-整体框架.ppt
《算法与设计算法分析基础-整体框架.ppt》由会员分享,可在线阅读,更多相关《算法与设计算法分析基础-整体框架.ppt(33页珍藏版)》请在三一办公上搜索。
1、2023/10/17,2,2007-2008-01Design and Analysis of AlgorithmsSCUEC,Review of last class,How to solve a problem by computer,The notion of algorithm,Actual problemMathematics modelAlgorithm design and analysisProgrammingResult analysis,Input output finiteness effectiveness definiteness,Algorithm design p
2、attern,2023/10/17,3,2007-2008-01Design and Analysis of AlgorithmsSCUEC,How to describe an algorithm?,Natural languageStep1 Input m and n.Step2 Divide m by n and assign the value of the remainder to r.Step3 If r=0,return the value of n as the answer and stop;otherwise,proceed to Step 4.Step4 Assign t
3、he value of n to m and the value of r to n.Step5 Go to Step2.,Advantages:easy understand,Disadvantages:exist inherent ambiguity,2023/10/17,4,2007-2008-01Design and Analysis of AlgorithmsSCUEC,How to describe an algorithm?(II),Flow chart,A flowchart is a method of expressing an algorithm by a collect
4、ion of connected geometric shapes containing descriptions of the algorithms steps.,Advantages:intuitive,Disadvantages:lack flexibility,2023/10/17,5,2007-2008-01Design and Analysis of AlgorithmsSCUEC,How to describe an algorithm?(III),Programming language,Advantages:can run on computer directly,Disad
5、vantages:lack abstraction,#include int GCD(int m,int n)int r=m%n;while(r!=0)m=n;n=r;r=m%n;return n;void main(void)cout GCD(60,24)endl;,2023/10/17,6,2007-2008-01Design and Analysis of AlgorithmsSCUEC,How to describe an algorithm?(IV),Pseudocode,1 r=m%n;2 While r0 2.1 m=n;2.2 n=r;2.3 r=m%n;3 return n;
6、,Advantages:more precise than natural language,A pseudocode is a mixture of a natural language and programming language.It uses the basic grammar of programming language,but the operation instructions can designed with natural language.,Disadvantages:not exist a single form of pseudocode,Fundamental
7、s of the Analysis of Algorithm Efficiency(I),Chapter 2,1、The framework to analyze algorithms 2、Best,worst,average-case analysis 3、Three asymptotic notations,2023/10/17,8,2007-2008-01Design and Analysis of AlgorithmsSCUEC,Goals of this lecture,At the end of this lecture,you should be able toDescribe
8、how to analyze an algorithmUnderstand what is a best-case,worse-case and average-case analysisMaster the three asymptotic notations,O,rate of growth,2023/10/17,9,2007-2008-01Design and Analysis of AlgorithmsSCUEC,Analysis of algorithms,Definition:Algorithm analysis means to evaluate the two computer
9、 resources,time and space,which needed by an algorithm.Less resources an algorithm needs,more efficiency it is.Issues:time efficiencyDetermines the amount of time that algorithm needs to be executed.space efficiencyDetermines the amount of space that algorithm needs to be executed.Approaches:theoret
10、ical analysisempirical analysis,2023/10/17,10,2007-2008-01Design and Analysis of AlgorithmsSCUEC,Goal:Determines the amount of time that an algorithm needs to be executedMethods:Determines the exact amount of time that an algorithm needs to be executed Determines the number of repetitions of all the
11、 operations as a function of input size and input instanceWhere N is the input size,I is the input instance.,Theoretical analysis of time efficiency,2023/10/17,11,2007-2008-01Design and Analysis of AlgorithmsSCUEC,Operations,ComparisonsEqual,greater,not equal,Logical operationsAnd,or,xor,not,Arithme
12、tic operationsAdditions:add,subtract,increment,decrementMultiplications:multiply,divide,modAssignment operationX=1For convenience,each elementary operation is considered to use 1 time unit.,2023/10/17,12,2007-2008-01Design and Analysis of AlgorithmsSCUEC,Size of Input,Sorting and Finding problems:nu
13、mber of element in the array or tableGraph algorithms:number of vertices or edges,or sum of bothComputational Geometry:usually number of points,vertices,edges,line segments,or polygons.Matrix Operation:dimension of matrixNumber theory and cryptography:number of bits of input number,2023/10/17,13,200
14、7-2008-01Design and Analysis of AlgorithmsSCUEC,Examples,xx+1,for j1 to n do xx+1repeat,T(N,I)=3nn additions,2n assignments,T(N,I)=21 addition,1 assignment,for i1 to n do for j1 to n do xx+1 repeatrepeat,T(n)=3n2+nn2 additions,2n2+n assignments,2023/10/17,14,2007-2008-01Design and Analysis of Algori
15、thmsSCUEC,Theoretical analysis of time efficiency,Determining the number of repetitions of the basic operation as a function of input size and input instanceBasic operation:the operation that contributes most towards the running time of the algorithm T(N,I)copC(N,I),running time,execution timefor ba
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 算法 设计 分析 基础 整体 框架
链接地址:https://www.31ppt.com/p-6329362.html