90 likes | 180 Vues
Learn about the intricacies of execution performance including time and space complexity of programs. Discover methods to estimate run time and predict growth in time complexity with asymptotic behavior. Explore common running time orders and categories to assess program efficiency.
E N D
Execution Performance • Space complexity • Time complexity
Space Complexity • The amount of memory that a program needs to run to completion • Instruction space • Data space • Environment space
Time Complexity • The amount of computer time a program needs to run to completion • Only attempts to estimate run time • Approaches: • Identify one or more key operations and determine the number of times that they are performed • Determine the total number of steps executed by the program
Operation Counts • To estimate the time complexity of a program • Identify one or more operations, such as add, multiply, and compare, and determine how many times each is performed • Select the operations that contribute most to the time complexity
Asymptotic Behavior • To predict the growth in run time as the problem size increases • Compare the time complexities of two or more programs
Large Problem Size • Asymptotic notation describes the behavior of the time or space complexity for large instance characteristics • The notation f(n) = O(g(n)) means that f(n) is asymptotically smaller than or equal to g(n) • In an asymptotic sense, g(n) is an upper bound for f(n).
Common running time (common order of magnitude) The order (in the descending order of efficiency: O(1) < O(logn) < O(n) < O(nlogn) < O(N2) < O(n3) <O(rn)
Running time in Big O notation Drop constants, coefficients Only care how T changes with input size, N Several categories of running time O(1), O(n), O(N2), O (logn) … etc. Figure 2.9 Table 2.5