Application: Efficiency of Algorithms I

Slides:



Advertisements
Similar presentations
Discrete Structures CISC 2315
Advertisements

February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
CompSci 102 Discrete Math for Computer Science
Real-Valued Functions of a Real Variable and Their Graphs
Lecture 7 CSE 331 Sep 16, Feedback forms VOLUNTARY Last 5 mins of the lecture.
Lecture 3 Aug 31, 2011 Goals: Chapter 2 (algorithm analysis) Examples: Selection sorting rules for algorithm analysis discussion of lab – permutation generation.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 2 Elements of complexity analysis Performance and efficiency Motivation: analysis.
Lecture 3 Feb 7, 2011 Goals: Chapter 2 (algorithm analysis) Examples: Selection sorting rules for algorithm analysis Image representation Image processing.
1 Section 2.3 Complexity of Algorithms. 2 Computational Complexity Measure of algorithm efficiency in terms of: –Time: how long it takes computer to solve.
Design and Analysis of Algorithms Chapter Analysis of Algorithms Dr. Ying Lu August 28, 2012
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
Real-Valued Functions of a Real Variable and Their Graphs Lecture 43 Section 9.1 Wed, Apr 18, 2007.
Chapter Complexity of Algorithms –Time Complexity –Understanding the complexity of Algorithms 1.
Chapter 2.6 Comparison of Algorithms modified from Clifford A. Shaffer and George Bebis.
Matt Schierholtz. Method for solving problems with finite steps Algorithm example: Error Check for problem Solve problem Must terminate.
DISCRETE MATHEMATICS I CHAPTER 11 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco.
Real-Valued Functions of a Real Variable and Their Graphs Lecture 38 Section 9.1 Mon, Mar 28, 2005.
Analysis of Algorithms
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Fall 2002CMSC Discrete Structures1 Enough Mathematical Appetizers! Let us look at something more interesting: Algorithms.
MCA-2012Data Structure1 Algorithms Rizwan Rehman CCS, DU.
Chapter 9 Efficiency of Algorithms. 9.1 Real Valued Functions.
Time Complexity of Algorithms
Asymptotic Behavior Algorithm : Design & Analysis [2]
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
CISC220 Spring 2010 James Atlas Lecture 07: Big O Notation.
1 The Role of Algorithms in Computing. 2 Computational problems A computational problem specifies an input-output relationship  What does the.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
LECTURE 9 CS203. Execution Time Suppose two algorithms perform the same task such as search (linear search vs. binary search) and sorting (selection sort.
CS1022 Computer Programming & Principles
Complexity Analysis (Part I)
Analysis of Algorithms
Reasons to study Data Structures & Algorithms
Introduction Algorithms Order Analysis of Algorithm
The Growth of Functions
Enough Mathematical Appetizers!
Computation.
Growth Functions Algorithms Lecture 8
Chapter 2: Getting Started
Section Euler’s Method
Algorithms Analysis Section 3.3 of Rosen Spring 2017
Applied Discrete Mathematics Week 6: Computation
Chapter 4, Section 2 Graphs of Motion.
Differentiator and Integrator Circuit
Noncomparison Based Sorting
Reasons to study Data Structures & Algorithms
Shell Sort and Merge Sort
Lecture 43 Section 10.1 Wed, Apr 6, 2005
Chapter 7 Functions and Graphs.
Time Complexity Lecture 14 Sec 10.4 Thu, Feb 22, 2007.
CSE 373 Data Structures and Algorithms
Dr.Surasak Mungsing CSE 221/ICT221 Analysis and Design of Algorithms Lecture 05-2: Analysis of time Complexity of Priority.
Enough Mathematical Appetizers!
Time Complexity Lecture 15 Mon, Feb 27, 2006.
Exponential and Logarithmic Functions
Enough Mathematical Appetizers!
Application: Efficiency of Algorithms II
slides created by Ethan Apter
Sum this up for me Let’s write a method to calculate the sum from 1 to some n public static int sum1(int n) { int sum = 0; for (int i = 1; i
Application: Efficiency of Algorithms II
Chapter 4, Section 2 Graphs of Motion.
CSE 373: Data Structures and Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Algorithms Analysis Section 3.3 of Rosen Spring 2013
Algorithms Analysis Section 3.3 of Rosen Spring 2018
Converting derived units.
Complexity Analysis (Part I)
Significant Digits Calculations.
Significant Digits Calculations.
Presentation transcript:

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.

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

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.

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

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

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 Rates x (1) (log x) (x) (x log x) (x2) 102 1 s 1.0 s 103 1.5 s 10 s 15 s 100 s 104 2.0 s 200 s 10 ms 105 2.5 s 1 ms 2.5 ms 1 sec 106 3.0 s 30 ms 1.7 min 107 3.5 s 100 ms 350 ms 2.8 hrs

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.

Comparison with (2x) x (x2) (2x) 100 1 s 110 1.2 s 1.0 ms 120 1.0 sec 130 1.7 s 18 min 140 2.0 s 13 days 150 2.3 s 36 yrs : 1000 100 s 2.7 x 10257 y

Comparison with (2x) x (x2) (2x) 100 1 s 110 1.2 s 1.0 ms 120 1.0 sec 130 1.7 s 18 min 140 2.0 s 13 days 150 2.3 s 36 yrs : 1000 100 s 2.7 x 10257 y x (1) (log x) (x) (x log x) (x2) 102 1 s 1.0 s 103 1.5 s 10 s 15 s 100 s 104 2.0 s 200 s 10 ms 105 2.5 s 1 ms 2.5 ms 1 sec 106 3.0 s 30 ms 1.7 min 107 3.5 s 100 ms 350 ms 2.8 hrs

Comparison with (2x) x (x2) (2x) 100 1 s 110 1.2 s 1.0 ms 120 1.0 sec 130 1.7 s 18 min 140 2.0 s 13 days 150 2.3 s 36 yrs : 1000 100 s 2.7 x 10257 y x (1) (log x) (x) (x log x) (x2) 102 1 s 1.0 s 103 1.5 s 10 s 15 s 100 s 104 2.0 s 200 s 10 ms 105 2.5 s 1 ms 2.5 ms 1 sec 106 3.0 s 30 ms 1.7 min 107 3.5 s 100 ms 350 ms 2.8 hrs

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.

Comparison with (x!) x (2x) (x!) 100 1 s 101 2 s 101 s 102 4 s 10 ms 103 8 s 1.1 sec 104 16 s 1.8 min 105 32 s 3.2 hrs : 110 1.0 ms 5.4 x 106 y

Comparison with (x!) x (2x) (x!) 100 1 s 101 2 s 101 s 102 4 s 10 ms 103 8 s 1.1 sec 104 16 s 1.8 min 105 32 s 3.2 hrs : 110 1.0 ms 5.3 x 106 y x (x2) (2x) 100 1 s 110 1.2 s 1.0 ms 120 1.4 s 1.0 sec 130 1.7 s 18 min 140 2.0 s 13 days 150 2.3 s 36 yrs : 1000 100 s 2.7 x 10257 y

Comparison with (x!) x (2x) (x!) 100 1 s 101 2 s 101 s 102 4 s 10 ms 103 8 s 1.1 sec 104 16 s 1.8 min 105 32 s 3.2 hrs : 110 1.0 ms 5.3 x 106 y x (x2) (2x) 100 1 s 110 1.2 s 1.0 ms 120 1.4 s 1.0 sec 130 1.7 s 18 min 140 2.0 s 13 days 150 2.3 s 36 yrs : 1000 100 s 2.7 x 10257 y

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