Menu. Lecture 2: Orders of Growth. Predicting Running Time. Order Notation. Predicting Program Properties

Similar documents
An analogy from Calculus: limits

Algorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc.

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

Lecture 3. Big-O notation, more recurrences!!

Please give details of your answer. A direct answer without explanation is not counted.

CS473 - Algorithms I

Math 31 Lesson Plan. Day 2: Sets; Binary Operations. Elizabeth Gillaspy. September 23, 2011

1.1 Administrative Stuff

CSC236 Week 4. Larry Zhang

MATH 22 FUNCTIONS: ORDER OF GROWTH. Lecture O: 10/21/2003. The old order changeth, yielding place to new. Tennyson, Idylls of the King

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

Countability. 1 Motivation. 2 Counting

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018

Math 31 Lesson Plan. Day 5: Intro to Groups. Elizabeth Gillaspy. September 28, 2011

Growth of Functions (CLRS 2.3,3)

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018

This chapter covers asymptotic analysis of function growth and big-o notation.

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

3.1 Asymptotic notation

Computational Complexity

CS103 Handout 08 Spring 2012 April 20, 2012 Problem Set 3

Omega notation. Transitivity etc.

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018

CSC236 Week 3. Larry Zhang

Asymptotic Analysis 1

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

Great Theoretical Ideas in Computer Science. Lecture 7: Introduction to Computational Complexity

Lecture 10: Big-Oh. Doina Precup With many thanks to Prakash Panagaden and Mathieu Blanchette. January 27, 2014

Linear Algebra. Instructor: Justin Ryan

CSE 373: Data Structures and Algorithms. Asymptotic Analysis. Autumn Shrirang (Shri) Mare

Math 2602 Finite and Linear Math Fall 14. Homework 8: Core solutions

Checkpoint Questions Due Monday, October 1 at 2:15 PM Remaining Questions Due Friday, October 5 at 2:15 PM

Algorithms and Their Complexity

Physics 321 Theoretical Mechanics I. University of Arizona Fall 2004 Prof. Erich W. Varnes

Guide to Proofs on Discrete Structures

PROFESSOR: WELCOME BACK TO THE LAST LECTURE OF THE SEMESTER. PLANNING TO DO TODAY WAS FINISH THE BOOK. FINISH SECTION 6.5

Algorithms and Programming I. Lecture#1 Spring 2015

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013

Mathematics E-15 Seminar on Limits Suggested Lesson Topics

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

Review 3. Andreas Klappenecker

Mathematical Logic Part One

Big Bang, Black Holes, No Math

Introduction to Algorithms 6.046J/18.401J

COE428 Notes Week 4 (Week of Jan 30, 2017)

EOS-310 Severe & Unusual Weather Spring, 2009 Associate Prof. Zafer Boybeyi 1/20/09

Math (P)Review Part I:

Asymptotic Analysis Cont'd

Course Staff. Textbook

Guide to Proofs on Sets

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0

Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2:

Lecture 1: Asymptotic Complexity. 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole.

NP-Completeness Review

Theory of Computation

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 10/31/16

One-to-one functions and onto functions

EECS 477: Introduction to algorithms. Lecture 5

Assignment 5 Bounding Complexities KEY

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

CS 4407 Algorithms Lecture 2: Growth Functions

1 Closest Pair of Points on the Plane

Preparing for the CS 173 (A) Fall 2018 Midterm 1

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality

Mathematical Logic Part One

On my honor I affirm that I have neither given nor received inappropriate aid in the completion of this exercise.

MATH 104, HOMEWORK #3 SOLUTIONS Due Thursday, February 4

CS173 Lecture B, November 3, 2015

An Algorithms-based Intro to Machine Learning

CSCE 222 Discrete Structures for Computing. Review for the Final. Hyunyoung Lee

MI 4 Mathematical Induction Name. Mathematical Induction

Great Theoretical Ideas in Computer Science. Lecture 9: Introduction to Computational Complexity

CS1210 Lecture 23 March 8, 2019

CS 4104 Data and Algorithm Analysis. CS4014: What You Need to Already Know. CS4104: What We Will Do. Introduction to Problem Solving (1)

Sequences and Series

Ch01. Analysis of Algorithms

Algebra Exam. Solutions and Grading Guide

Foundations II: Data Structures and Algorithms

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17

The Time Complexity of an Algorithm

Methods of Mathematics

P, NP, NP-Complete, and NPhard

FOUNDATIONS OF ALGEBRAIC GEOMETRY CLASS 2

CS483 Design and Analysis of Algorithms

Day 1: Over + Over Again

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2

NP-Completeness Part II

CSE 241 Class 1. Jeremy Buhler. August 24,

Math 3012 Applied Combinatorics Lecture 5

Class 24: Computability

Ch 01. Analysis of Algorithms

CS173 Running Time and Big-O. Tandy Warnow

Sequence convergence, the weak T-axioms, and first countability

Class 7 Preclass Quiz on MasteringPhysics

Main topics for the First Midterm Exam

COS 341: Discrete Mathematics

Math 138: Introduction to solving systems of equations with matrices. The Concept of Balance for Systems of Equations

Introduction to Cryptography

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Transcription:

CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 2: Orders of Growth Menu Predicting program properties Orders of Growth: O, Ω Course Survey Results Everyone should have received an email: 1.Informing you of your PS1 partner 2.Giving the section room locations 3.Explaining that PS1 is now due Monday, Jan 30 http://www.cs.virginia.edu/cs216 2 Predicting Program Properties We ve tried to take steps to try and mitigate the problems by moving administrators off the system, making some improvements to the code, Webb said. Unfortunately, to see whether it works, students need to be on the system. Cavalier Daily, Friday Jan 20 (http://www.cavalierdaily.com/cvarticle.asp?id=25481) 3 4 Predicting Running Time Experimentally: measure how long the program takes on particular inputs Generalize, extrapolate to other input sizes Analytically: figure out how the amount of work scales with the input size Understand what the program does Need to combine with experimental results on some inputs and analytical understanding to make good predictions Order Notation Four notations:o( f ), Ω( f ), o( f ), Θ( f ) These notations define sets of functions Functions from positive integer to real When we say, Algorithm A is O(n) we mean, running time of A O (n) where n measures the input size to A. 5 6 1

Big O Intuition: the set O(f) is the set of functions that grow no faster than f More formal definition coming soon Asymptotic growth rate As input to f approaches infinity, how fast does value of f increase Hence, only the fastest-growing term in f matters: O(n 3 ) O(12n 2 + n) O(n) O(63n + log n 423) Examples O(n 3 ) Faster Growing 7 8 Formal Definition O Examples f O (g) means: There are positive constants c and n 0 such that f(n) cg(n) for all values n n 0. f (n) O (g (n)) means: there are positive constants c and n 0 such that f(n) cg(n) for all values n n 0. x O (x 2 )? 10x O (x)? Yes, c = 1, n 0 =2 works fine. Yes, c = 11, n 0 =2 works fine. x 2 O (x)? No, no matter what c and n 0 we pick, cx 2 > x for big enough x 9 10 Question Given f O (h) and g O (h) which of these are true: a. For all positive integers m, b. For some positive integer m, c. For some positive integer m 0, and all positive integers m > m 0, (left as problem for Exam 1) a is false: Prove by Counter-Example f (n) O (h (n)) and g (n) O (h (n)) a. For all positive integers m, Pick h (n) = n 2, f (n) = 5n 2, g(n)= n 3. For m = 2, f (m) = 20 > 8 = g(m). Therefore, a is false. f (n) O (g (n)) means there are positive constants c and n 0 such that f(n) cg(n) for all values n n 0. 11 12 2

b is true: Intuition positive integer m, g must grow faster than h, otherwise g would be in O(h). f must grow no faster than h, since f O (h) So, if g grows faster than h, but f grows as slow or slower than h, eventually, g(n) > f (n) so for some m, b: Proof by Contradiction positive integer m, 1. f O (h) there are positive constants c and n 0 such that f(n) ch(n) for all values n n 0 2. g O (h) there are no positive constants c 1 and n 1 such that g(n) c 1 h(n) for all values n n 1. So, for all positive constants c 2, g(q) c 2 h(q) for some value q. 13 14 b: Proof by Contradiction positive integer m, Suppose statement is false. Then, for all positive k, f(k) g(k) From (1), c n 0 such that n > n 0, f(n) ch(n) From (2), c 1 n 1 such that n > n 1, g(n) > c 1 h(n) Combining, c c 1 n 2 such that n > n 2 ch(n) > c 1 h(n) Note: n 2 max(n 0, n 1 ) This is a contradiction! Only works if c = infinity, but c must be a positive integer Lower Bound: Ω (Omega) f(n) is Ω (g (n)) means: There are positive constants c and such that f (n) cg(n) for all n n 0. Difference from O this was 15 16 Where is Ω(n 2 )? O(n 3 ) Inside-Out Ω(n 3 ) Ω(n 2 ) Ω(n 2 ) Faster Growing Slower Growing 17 18 3

Honor Questions Survey Results Summary See course web site for more detailed results How much faith do you think we should put in the honor system for this class? 30 Should have complete trust in honor system 43 Enough to have take-home exams 6 A little, but don't trust take-home exams 1 Don't trust the students at all, need to police everything 73/80 Exam 1 will be take home 19 20 Honor Disadvantage? Do you feel you are at a disadvantage if you follow the course honor policy strictly? 69 no 11 yes I hope the majority answer here will help convince the 11 yes answered they are not really at a disadvantage. Long term, being honorable is never a disadvantage. Honor Reporting If you observed a classmate cheating on a take-home exam, what would you do? 36 Report the student anonymously to the course staff 20 Confront the student 11 Report the student to the course staff 8 Nothing 3 Initiate an honor charge 2 No Selection Course Pledge disallows this now. If you can t handle this, don t sign the course pledge and take a different class. 21 22 Course Pledge Read this carefully you are expected to know it and follow it Only pledge you need to sign this semester Requires: No lying, cheating, or stealing Helping your classmates learn No toleration of dishonorable behavior Helping the course staff improve the course Programming Self-Rating 4 among best 26 above average 41 about average 8 a little below, far below The programming you will do in this class is different enough from what you have done previously, that you probably don t really know. Everyone should be confident you will do well in this class. You don t need to be a super code hacker to ace this class. 23 24 4

Programming Languages Python: 74 Not at all 6 Some familiarity Any assembly language: 72 Not at All 7 Some familiarity 1 Lots of experience Survey Results More results (as well as my answers to the questions you asked) are posted on the course web page Very few of you have experience with the language we use in this class (that is part of why we use them). You should not be worried about this! 25 26 Charge Sections meet today and tomorrow Order Notation practice Recurrence Relations Wednesday: Levels of Abstraction, Introducing Lists Read Chapter 3 in the textbook 27 5