《数据结构的算法在C++中的应用》(英文版)Chapter 2 Program performance

Chapter 2 Program performance
Chapter 2 Program performance

2.1 Preface Performance of a program: the amount of computer memory and time needed to run a program We use two approaches to determine it performance analysIs performance measurement
2.1 Preface Performance of a program: the amount of computer memory and time needed to run a program We use two approaches to determine it: performance analysis performance measurement

2.1 Preface Space complexity: the amount of memory a program needs to run to completion Time complexity the amount of time a program needs to run to completion
2.1 Preface Space complexity: the amount of memory a program needs to run to completion Time complexity: the amount of time a program needs to run to completion

2.2 Space Complexity 1) components Instruction space data space (space needed for constants, simple variables, component variables environment stack space( to save information needed to resume execution of partially completed nctions
2.2 Space Complexity 1)components: instruction space data space (space needed for constants,simple variables,component variables) environment stack space (to save information needed to resume execution of partially completed functions)

2.2 Space Complexity two parts a fixed part--include space for instructions, simple variables fixed-size component variables. constants a variable part--include space for component variables, dynamical allocated space, recursion stack S(p=C+S,(instance characteristics)
2.2 Space Complexity two parts: a fixed part—include space for instructions,simple variables,fixed-size component variables,constants a variable part—include space for component variables,dynamical allocated space,recursion stack S(p)=c+Sp (instance characteristics)

2.2 Space Complexity 2 )example Sequential Search(program 2.1) Template int Sequential Search(T all, const T&x, int n) int 1 for(i=0;i<n&&a[i]!x,i++); If(i==return return 1
2.2 Space Complexity 2)example: • Sequential Search (program 2.1) Template int SequentialSearch(T a[], const T&x, int n) { int i; for(i=0; i<n&&a[i]!=x; i++) ; If(i= =n)return –1; return i; }

2.2 Space Complexity Total data space 12 bytes( x, i, a[1],,-1, n, each of them cost 2 bytes)
2.2 Space Complexity Total data space: 12 bytes( x,i,a[i],0,-1,n, each of them cost 2 bytes) S(n)=0

2.2 Space Complexity Recursive code to add a[0 n-1(Program 1.9) Template T Rsumtal l, int n) f if(n>0 return Rsum (a, n-1)+an-1 return 0
2.2 Space Complexity • Recursive code to add a[0:n-1] (Program 1.9) Template T Rsum(T a[ ], int n) { if ( n>0 ) return Rsum(a, n-1) + a[n-1]; return 0; }

2.2 Space Complexity Recursion stack space formal parameters: a(2 byte), n (2 byte) return address(2 byte) Depth of recursion: n+1 SSum(n)=6(n+1)
2.2 Space Complexity 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)

2.3 Time complexity The time taken by a program p is t(p) T(p=compile timetrun time The compile time does not depend on the instance characteristics The run time is denoted by t(instance characteristics) D)operation counts identify one or more key operations and determine the num ber of times these are performed
2.3 Time complexity The time taken by a program p is T(p) T(p)=compile time+run time The compile 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
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《数据结构的算法在C++中的应用》(英文版)Chapter 1 preface.ppt
- 《数据结构的算法在C++中的应用》(英文版)Textbook.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第9章 宏.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第8章 数据访问页.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第7章 建立Access报表.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第6章 Access窗体的操作.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第5章 查询的创建及应用.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第4章 建构Access数据库表.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第3章 创建Access数据库.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第2章 Access 2002应用基础.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第1章 数据库原理及基本概念.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第12章 综合实例应用.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第11章 Access数据库的管理.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)第10章 Access模块和应用程序设计.ppt
- 《Access数据库应用教程》教学资源(PPT课件讲稿)各章习题参考答案.ppt
- 西北工业大学:《计算机系统结构》总复习及模拟试题.ppt
- 西北工业大学:《计算机系统结构》总复习.ppt
- 西北工业大学:《计算机系统结构》第4章 直接映象及其变换.ppt
- 西北工业大学:《计算机系统结构》第3章 习题处理.ppt
- 西北工业大学:《计算机系统结构》第4章 存贮体系.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 3 Linear List.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 4 Arrays and Matrix.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 5 Stack.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 6 Queue.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 7 Hashing.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 8 Binary and other trees.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 9 Priority Queues.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 11 Search Trees.ppt
- 《数据结构的算法在C++中的应用》(英文版)Chapter 12 Graphs.ppt
- 四川电力职业技术学院:《ASP网络程序设计》目录.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第五章 数据库基础知识.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第二章 ASP初步.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第一章 网络程序设计概述.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第三章 ASP脚本语 VBScript.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第四章 ASP常用内部对象.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第六章 ASP数据库编程.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第八章 使用第三方组件.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第七章 文件存取组件及其它组.ppt
- 四川电力职业技术学院:《ASP网络程序设计》第一章 网络程序设计概述.ppt
- 《ASP动态网页设计》电子教案.doc