1 / 17

Application: Efficiency of Algorithms I

Application: Efficiency of Algorithms I. Lecture 40 Section 9.3 Thu, Mar 31, 2005. Estimating 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 form t = cf ( x ) for some real number c.

marcosv
Download Presentation

Application: Efficiency of Algorithms I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Application: Efficiency of Algorithms I Lecture 40 Section 9.3 Thu, Mar 31, 2005

  2. Estimating 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 form t = cf(x) for some real number c.

  3. Estimating Run Times • Suppose the program runs in t0 seconds when the input size is x0. Then c = t0/f(x0). • Thus, the run time is given by

  4. Example: 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 by t = 5(x2/1002) s. • Thus, if input size were 500, then the run time would t = 55002/1002 = 125 s.

  5. 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

  6. Example: Estimating Run Time • Thus, if input size were 500, then the run time would be

  7. 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.

  8. Comparison of Growth Rates

  9. Comparison 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.

  10. Comparison with (2x)

  11. Comparison with (2x)

  12. Comparison with (2x)

  13. Comparison 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.

  14. Comparison with (x!)

  15. Comparison with (x!)

  16. Comparison with (x!)

  17. Tractable 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 digits).

More Related