H-SC MATH 262 - Lecture 40 - Application - Efficiency of Algorithms I

Unformatted text preview:

Application: Efficiency of Algorithms IEstimating Run TimesSlide 3Example: Estimating Run TimeSlide 5Slide 6Comparison of Growth RatesSlide 8Comparison with (2x)Slide 10Slide 11Slide 12Comparison with (x!)Slide 14Slide 15Slide 16Tractable vs. IntractableApplication: Efficiency of Algorithms ILecture 40Section 9.3Thu, Mar 31, 2005Estimating Run TimesSuppose the run-time of a program has growth rate (f(x)), where x is the input size.Then the run-time is (approx.) of the formt = cf(x)for some real number c.Estimating Run TimesSuppose the program runs in t0 seconds when the input size is x0. Thenc = t0/f(x0).Thus, the run time is given by.)()()()(0000xfxftxfxfttExample: Estimating Run TimeSuppose a program has growth rate (x2) and that the program runs in t0 = 5 s when the input size is x0 = 100.Then the run time is given byt = 5(x2/1002) s.Thus, if input size were 500, then the run time wouldt = 55002/1002 = 125 s.Example: Estimating Run TimeSuppose a program has growth rate (x log x).and that the program runs in t0 = 5 s when the input size is x0 = 100.Then the run time is.s 100log100log5xxExample: Estimating Run TimeThus, if input size were 500, then the run time would bes. 7.33100log100500log5005Comparison of Growth RatesConsider programs with growth rates of (1), (log x), (x), (x log x), and (x2).Assume that each program runs in 1 s when the input size is 100.Calculate the run times for input sizes 102, 103, 104, 105, 106, and 107.Comparison of Growth Ratesx(1) (log x) (x) (x log x) (x2)1021 s 1.0 s 1 s 1 s 1 s1031 s 1.5 s 10 s 15 s 100 s1041 s 2.0 s 100 s 200 s10 ms1051 s 2.5 s1 ms 2.5 ms 1 sec1061 s 3.0 s10 ms 30 ms 1.7 min1071 s 3.5 s100 ms 350 ms 2.8 hrsComparison with (2x)Now consider a program with growth rate (2x).Assume that the program runs in 1 s when the input size is 100.Calculate the run times for input sizes 100, 110, 120, 130, 140, and 150.Comparison with (2x)x(x2) (2x)1001 s 1 s1101.2 s1.0 ms1201.4 s1.0 sec1301.7 s18 min1402.0 s13 days1502.3 s36 yrs: : :1000100 s2.7 x 10257 yComparison with (2x)x(x2) (2x)1001 s 1 s1101.2 s1.0 ms1201.4 s1.0 sec1301.7 s18 min1402.0 s13 days1502.3 s36 yrs: : :1000100 s2.7 x 10257 yx(1) (log x) (x) (x log x) (x2)1021 s 1.0 s 1 s 1 s 1 s1031 s 1.5 s 10 s 15 s 100 s1041 s 2.0 s 100 s 200 s10 ms1051 s 2.5 s1 ms 2.5 ms 1 sec1061 s 3.0 s10 ms 30 ms 1.7 min1071 s 3.5 s100 ms 350 ms 2.8 hrsComparison with (2x)x(x2) (2x)1001 s 1 s1101.2 s1.0 ms1201.4 s1.0 sec1301.7 s18 min1402.0 s13 days1502.3 s36 yrs: : :1000100 s2.7 x 10257 yx(1) (log x) (x) (x log x) (x2)1021 s 1.0 s 1 s 1 s 1 s1031 s 1.5 s 10 s 15 s 100 s1041 s 2.0 s 100 s 200 s10 ms1051 s 2.5 s1 ms 2.5 ms 1 sec1061 s 3.0 s10 ms 30 ms 1.7 min1071 s 3.5 s100 ms 350 ms 2.8 hrsComparison with (x!)Now consider a program with growth rate (x!).Assume that the program runs in 1 s when the input size is 100.Calculate the run times for input sizes 100, 101, 102, 103, 104, and 105.Comparison with (x!)x(2x) (x!)1001 s 1 s1012 s 101 s1024 s10 ms1038 s1.1 sec10416 s1.8 min10532 s3.2 hrs: : :110 1.0 ms 5.4 x 106 yComparison with (x!)x(2x) (x!)1001 s 1 s1012 s 101 s1024 s10 ms1038 s1.1 sec10416 s1.8 min10532 s3.2 hrs: : :110 1.0 ms 5.3 x 106 yx(x2) (2x)1001 s 1 s1101.2 s1.0 ms1201.4 s1.0 sec1301.7 s18 min1402.0 s13 days1502.3 s36 yrs: : :1000100 s2.7 x 10257 yComparison with (x!)x(2x) (x!)1001 s 1 s1012 s 101 s1024 s10 ms1038 s1.1 sec10416 s1.8 min10532 s3.2 hrs: : :110 1.0 ms 5.3 x 106 yx(x2) (2x)1001 s 1 s1101.2 s1.0 ms1201.4 s1.0 sec1301.7 s18 min1402.0 s13 days1502.3 s36 yrs: : :1000100 s2.7 x 10257 yTractable vs. IntractableAlgorithms that are O(xd), for some d > 0, are considered tractable.Algorithms that are not O(xd), for some d > 0, are considered intractable.Of course, all algorithms are do-able for small input sizes.It is practical to factor small integers (< 50 digits).It is impractical to factor large integers (> 200


View Full Document
Download Lecture 40 - Application - Efficiency of Algorithms I
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 40 - Application - Efficiency of Algorithms I and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 40 - Application - Efficiency of Algorithms I 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?