CS 312: Algorithm Design & Analysis Lecture #2: Asymptotic Notation This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

 The running time of an algorithm as input size approaches infinity is called the asymptotic running time  We study different notations for asymptotic.
CSE 373 Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III.
Lecture 1: Overview CMSC 201 Computer Science 1 (Prof. Chang version)
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
CISC220 Spring 2010 James Atlas Lecture 06: Linked Lists (2), Big O Notation.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 8+9 Time complexity 1 Jan Maluszynski, IDA, 2007
Design and Analysis of Algorithms Chapter Analysis of Algorithms Dr. Ying Lu August 28, 2012
COMPSCI 102 Introduction to Discrete Mathematics.
CS Algorithm Analysis1 Algorithm Analysis - CS 312 Professor Tony Martinez.
CS 312: Algorithm Analysis Lecture #3: Algorithms for Modular Arithmetic, Modular Exponentiation This work is licensed under a Creative Commons Attribution-Share.
CS 312: Algorithm Analysis
CS 312: Algorithm Design & Analysis Lecture #34: Branch and Bound Design Options for Solving the TSP: Tight Bounds This work is licensed under a Creative.
Lecture 8. How to Form Recursive relations 1. Recap Asymptotic analysis helps to highlight the order of growth of functions to compare algorithms Common.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
CS 3343: Analysis of Algorithms
CS 312: Algorithm Analysis Lecture #8: Non-Homogeneous Recurrence Relations This work is licensed under a Creative Commons Attribution-Share Alike 3.0.
CS 221 Analysis of Algorithms Instructor: Don McLaughlin.
1 COMP3040 Tutorial 1 Analysis of algorithms. 2 Outline Motivation Analysis of algorithms Examples Practice questions.
Analysis of Algorithms These slides are a modified version of the slides used by Prof. Eltabakh in his offering of CS2223 in D term 2013.
Télécom 2A – Algo Complexity (1) Time Complexity and the divide and conquer strategy Or : how to measure algorithm run-time And : design efficient algorithms.
CS 312: Algorithm Analysis Lecture #32: Intro. to State-Space Search This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.
Discrete Mathematics CS204 Spring CS204 Discrete Mathematics Instructor: Professor Chin-Wan Chung (Office: Rm 3406, Tel:3537) 1.Lecture 1)Time:
Complexity A decidable problem is computationally solvable. But what resources are needed to solve the problem? –How much time will it require? –How much.
CS 312: Algorithm Design & Analysis Lecture #23: Making Optimal Change with Dynamic Programming Slides by: Eric Ringger, with contributions from Mike Jones,
CS 312: Algorithm Design & Analysis Lecture #12: Average Case Analysis of Quicksort This work is licensed under a Creative Commons Attribution-Share Alike.
CS 312: Algorithm Analysis Lecture #1: Algorithms and Efficiency This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CS 312: Algorithm Design & Analysis Lecture #24: Optimality, Gene Sequence Alignment This work is licensed under a Creative Commons Attribution-Share Alike.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CS 312: Algorithm Design & Analysis Lecture #35: Branch and Bound Design Options: State Spaces Slides by: Eric Ringger, with contributions from Mike Jones,
Design and Analysis of Algorithms Chapter Asymptotic Notations* Dr. Ying Lu August 30, RAIK.
Computer Science and Software Engineering University of Wisconsin - Platteville 8. Comparison of Algorithms Yan Shi CS/SE 2630 Lecture Notes Part of this.
CS 312: Algorithm Analysis Lecture #1: Algorithms and Efficiency This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Algorithm Analysis Part of slides are borrowed from UST.
CS 312: Algorithm Design & Analysis Lecture #37: A* (cont.); Admissible Heuristics Credit: adapted from slides by Stuart Russell of UC Berkeley. This work.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
CSE 373: Data Structures and Algorithms
CS 312: Algorithm Analysis Lecture #7: Recurrence Relations a.k.a. Difference Equations Slides by: Eric Ringger, with contributions from Mike Jones, Eric.
CS 312: Algorithm Analysis Lecture #8: Non-Homogeneous Recurrence Relations This work is licensed under a Creative Commons Attribution-Share Alike 3.0.
CS 312: Algorithm Analysis
CS 312: Algorithm Analysis Lecture #31: Linear Programming: the Simplex Algorithm, part 2 This work is licensed under a Creative Commons Attribution-Share.
CS 312: Algorithm Analysis Lecture #35: Branch and Bound Design Options - State Spaces Slides by: Eric Ringger, with contributions from Mike Jones, Eric.
CISC220 Spring 2010 James Atlas Lecture 07: Big O Notation.
CS 312: Algorithm Analysis Lecture #31: Linear Programming: the Simplex Algorithm, part 2 This work is licensed under a Creative Commons Attribution-Share.
2IL50 Data Structures Spring 2016 Lecture 2: Analysis of Algorithms.
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 3 Algorithms.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Computer Networks CNT5106C
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 4.
CS 312: Algorithm Analysis Lecture #9: Recurrence Relations - Change of Variable Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer,
CS 312: Algorithm Design & Analysis Lecture #26: 0/1 Knapsack This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CS 312: Algorithm Analysis Lecture #30: Linear Programming: Intro. to the Simplex Algorithm This work is licensed under a Creative Commons Attribution-Share.
LECTURE 2 : fundamentals of analysis of algorithm efficiency Introduction to design and analysis algorithm 1.
Analysis of Algorithmic Efficiency
Lecture 06: Linked Lists (2), Big O Notation
Algorithm Analysis Neil Tang 01/22/2008
CS 3343: Analysis of Algorithms
Asymptotic Notations Algorithms Lecture 9.
Foundations II: Data Structures and Algorithms
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
COSC 320 Advanced Data Structures and Algorithm Analysis
CS 201 Fundamental Structures of Computer Science
Introduction to Discrete Mathematics
COMPSCI 330 Design and Analysis of Algorithms
At the end of this session, learner will be able to:
Richard Anderson Winter 2019 Lecture 4
David Kauchak cs161 Summer 2009
Richard Anderson Autumn 2015 Lecture 4
Presentation transcript:

CS 312: Algorithm Design & Analysis Lecture #2: Asymptotic Notation This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative Commons Attribution-Share Alike 3.0 Unported License Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, Sean Warnick

Pop Quiz 1.What is the reward for submitting project reports early? 2.How many penalty-free late days are in your budget for the semester? 3.How many penalty-free late days can you use on any one project? 4.What is the penalty for late submission of project reports (after you’ve used your penalty-free late days)? 5.What is the time of day for project deadlines? 6.T/F: You may submit late regular homework assignments. 7.T/F: You can do a whiteboard experience alone.

Announcements  TA and instructor office hours are on the course wiki  Project #1  Due dates on the schedule  Instructions linked from the online schedule  We’ll cover the mathematical ideas in class  Help session with TA  Purpose of help sessions  HW #0  C# surprises?

Objectives  Revisit orders of growth  Formally introduce asymptotic notation: O,   Classify functions in asymptotic orders of growth

Orders of Growth

nlog 2 nnnlog 2 nn2n2 n3n * * * * * *

Orders of Growth nlog 2 nnnlog 2 nn2n2 n3n3 2n2n n!n! * ~10 3 ~3.6* * ~1.3*10 30 ~9* * …… * * * Efficient

Kinds of Efficiency  Need to decide which instance of a given size to use as the representative for that class: Algorithm Domain Instance size Instances Average Case (over all possible instances) Worst Case Best Case

Asymptotic Notation

Definitions: given an asymptotically non-negative fn. g(n),

Notational Convention

Asymptotic Notation f(n) c g(n) n0n0 f(n) c g(n) n0n0 n0n0 c 1 g(n) c 2 g(n) f(n)

Cases vs. Orders

Example Show that Must find positive constants c 1, c 2, n 0 such that Divide through by n 2 to get This proof is constructive

Another Example

Other proof types?  Induction  Optional example on HW #1  Deduction  Others!

Duality

g(n) in O(f(n)) means all instances of size n are solvable within c 1 f(n) time. f(n) in Ω(g(n)) means at least one instance of size n is solvable in c 2 g(n) time. … for worst case performance.

Duality Suppose t(n) models worst case behavior of an algorithm. Then t(n) = O(n!) means every instance of size n is solvable in factorial time. Then t(n) =  (n!) means at least one instance of size n requires factorial time. But infinitely many size-n instances may require n 2 time! Using our definition of , a  bound on the worst case isn’t useful. 1. Change the definition. But then duality fails. 2. Live with it. That’s what we’ll do. Similarly, using duality we also conclude that a O bound on a best case isn’t useful!

The Limit Rule

Example

Useful Identity: L’Hopital’s Rule

Review: Log Identities

Review: More Logarithms

Assignment  HW #1: 0.1 (a-e, g, m) in the textbook  Problems like these will appear on the mid-term and final exams  Justify your answers and show your work  Remember:  Don’t spend more than 2 focused hours on the homework exercises.  If you reach 2 hours of concentrated effort, stop and make a note to that effect on your paper (unless you’re having fun and want to continue).  The TAs will take that into consideration when grading.

 The following slides are extra

Addition

Multiplication

Classic Multiplication 5001 x x American Style English Style O(n 2 ) for 2 n-digit numbers

Multiplication a la Francais / Russe

Mulitplication a la Francais / Russe function multiply(x,y) Input: Two n-bit integers x and y, where y  0 Output: Their product if y = 0: return 0 if y = 1: return x z = multiply(x, floor(y/2)) if y is even: return 2z else: return x+2z

Mulitplication a la Francais / Russe function multiply(x,y) Input: Two n-bit integers x and y, where y  0 Output: Their product if y = 0: return 0 if y = 1: return x z = multiply(x, floor(y/2)) if y is even: return 2z else: return x+2z

Mulitplication a la Francais / Russe function multiply(x,y) Input: Two n-bit integers x and y, where y>=0 Output: Their product if y = 0: return 0 if y = 1: return x z = multiply(x, floor(y/2)) if y is even: return 2z else: return x+2z

Multiplication a la russe Don’t need to know multiplication tables Just need to know how to double, halve, and add!

Multiplication a la russe x = = O(n 2 )

Arabic Multiplication

Division function divide(x,y) Input: Two n-bit integers x and y, where y  1 Output: The quotient and remainder of x divided by y if x=0: return (q, r) = (0,0) (q, r) = divide(floor(x/2),y) q=2*q, r=2*r if x is odd: r=r+1 if r  y: r=r-y, q=q+1 return (q, r)

Division function divide(x,y) Input: Two n-bit integers x and y, where y  1 Output: The quotient and remainder of x divided by y if x=0: return (q, r) = (0,0) (q, r) = divide(floor(x/2),y) q=2*q, r=2*r if x is odd: r=r+1 if r  y: r=r-y, q=q+1 return (q, r)