1 Discrete Mathematics Summer 2004 By Dan Barrish-Flood originally for Fundamental Algorithms For use by Harper Langston in D.M.

Slides:



Advertisements
Similar presentations
Intro to Analysis of Algorithms. Algorithm “A sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any.
Advertisements

Algorithmic Complexity Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Asymptotic Growth Rate
Not all algorithms are created equally Insertion of words from a dictionary into a sorted list takes a very long time. Insertion of the same words into.
Introduction to Analysis of Algorithms
Not all algorithms are created equally Insertion of words from a dictionary into a sorted list takes a very long time. Insertion of the same words into.
Analysis of Algorithms (Chapter 4)
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
Cmpt-225 Algorithm Efficiency.
CSE 830: Design and Theory of Algorithms Dr. Eric Torng.
CS3381 Des & Anal of Alg ( SemA) City Univ of HK / Dept of CS / Helena Wong 2. Analysis of Algorithms - 1 Analysis.
25 June 2015Comp 122, Spring 2004 Asymptotic Notation, Review of Functions & Summations.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 2 Elements of complexity analysis Performance and efficiency Motivation: analysis.
Summary of Algo Analysis / Slide 1 Algorithm complexity * Bounds are for the algorithms, rather than programs n programs are just implementations of an.
Text Chapters 1, 2. Sorting ä Sorting Problem: ä Input: A sequence of n numbers ä Output: A permutation (reordering) of the input sequence such that:
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
David Luebke 1 8/17/2015 CS 332: Algorithms Asymptotic Performance.
Insertion Sort CSE 331 Section 2 James Daly. Insertion Sort Basic idea: keep a sublist sorted, then add new items into the correct place to keep it sorted.
Algorithm Analysis (Big O)
CSE 5311 DESIGN AND ANALYSIS OF ALGORITHMS. Definitions of Algorithm A mathematical relation between an observed quantity and a variable used in a step-by-step.
Analysis of Performance
1 Chapter 2 Program Performance – Part 2. 2 Step Counts Instead of accounting for the time spent on chosen operations, the step-count method accounts.
Algorithm Analysis & Complexity We saw that a linear search used n comparisons in the worst case (for an array of size n) and binary search had logn comparisons.
Program Performance & Asymptotic Notations CSE, POSTECH.
1 ©2008 DEEDS Group Introduction to Computer Science 2 - SS 08 Asymptotic Complexity Introduction in Computer Science 2 Asymptotic Complexity DEEDS Group.
Lecture 2 Computational Complexity
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
Mathematics Review and Asymptotic Notation
CSC 201 Analysis and Design of Algorithms Lecture 04: CSC 201 Analysis and Design of Algorithms Lecture 04: Time complexity analysis in form of Big-Oh.
Iterative Algorithm Analysis & Asymptotic Notations
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.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 4.
Analysis of Algorithms
Introduction to Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
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.
Asymptotic Analysis-Ch. 3
Introduction to Analysis of Algorithms COMP171 Fall 2005.
Algorithms Growth of Functions. Some Notation NNatural numbers RReal numbers N + Positive natural numbers R + Positive real numbers R * Non-negative real.
Algorithm Analysis (Algorithm Complexity). Correctness is Not Enough It isn’t sufficient that our algorithms perform the required tasks. We want them.
Asymptotic Notation (O, Ω, )
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
RUNNING TIME 10.4 – 10.5 (P. 551 – 555). RUNNING TIME analysis of algorithms involves analyzing their effectiveness analysis of algorithms involves analyzing.
Algorithmic Analysis Charl du Plessis and Robert Ketteringham.
Time Complexity of Algorithms (Asymptotic Notations)
Algorithm Analysis Part of slides are borrowed from UST.
Big-O. Algorithm Analysis Exact analysis: produce a function f(n) measuring how many basic steps are needed for a given inputs n On any input of size.
Chapter 7 Analysis of Algorithms © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
Asymptotic Performance. Review: Asymptotic Performance Asymptotic performance: How does algorithm behave as the problem size gets very large? Running.
CS 150: Analysis of Algorithms. Goals for this Unit Begin a focus on data structures and algorithms Understand the nature of the performance of algorithms.
E.G.M. PetrakisAlgorithm Analysis1  Algorithms that are equally correct can vary in their utilization of computational resources  time and memory  a.
13 February 2016 Asymptotic Notation, Review of Functions & Summations.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Big O David Kauchak cs302 Spring Administrative Assignment 1: how’d it go? Assignment 2: out soon… Lab code.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
1 Asymptotes: Why? How to describe an algorithm’s running time? (or space, …) How does the running time depend on the input? T(x) = running time for instance.
Analysis of Algorithms: Methods and Examples CSE 2320 – Algorithms and Data Structures Vassilis Athitsos Modified by Alexandra Stefan University of Texas.
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.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong
Introduction to Algorithms
Asymptotic Notations Algorithms Lecture 9.
Asymptotes: Why? How to describe an algorithm’s running time?
Chapter 2.
Discrete Mathematics 7th edition, 2009
David Kauchak cs161 Summer 2009
CS210- Lecture 2 Jun 2, 2005 Announcements Questions
Presentation transcript:

1 Discrete Mathematics Summer 2004 By Dan Barrish-Flood originally for Fundamental Algorithms For use by Harper Langston in D.M.

2 A problem is a precise specification of input and desired output An algorithm is a precise specification of a method for solving a problem. What is an Algorithm?

3 What We Want in an Algorithm Correctness –Always halts –Always gives the right answer Efficiency –Time –Space Simplicity

4 A Typical Problem Sorting Input: A sequence b 1, b 2,... b n Output: A permutation of that sequence b 1, b 2,... b n such that

5 A Typical Algorithm

6 Running Time t J is the number of times the “while” loop test in line 5 is executed for that value of j. Total running time is c 1 (n) + c 2 (n-1) +…+c 8 (n-1)

7 Trying to determine the exact running time is tedious, complicated and platform-specific. Instead, we’ll bound the worst-case running time to within a constant factor for large inputs. Why worst-case? –It’s easier. –It’s a guarantee. –It’s well-defined. –Average case is often no better. A Better Way to Estimate Running Time

8 Insertion Sort, Redux Outer loop happens about n times. Inner loop is done j times for each j, worst case. j is always < n So running time is upper-bounded by about  “Insertion sort runs in  (n 2 ) time, worst-case.”

9 We’ll make all the “about”s and “rough”s precise. These so-called asymptotic running times dominate constant factors for large enough inputs.

10 Functions constants polynomials exponentials logarithms and polylogarithms factorial

11 Polynomials

12 f(n) is monotonically increasing iff I.e. It never “goes down” — always increases or stays the same. For strictly increasing, replace  in the above with <. I.e. The function is always going up.

13 Are constant functions monotonically increasing? Yes! (But not strictly increasing.) If, then is strictly increasing. So even increases forever to

14 Exponentials

15 Logarithms

16 Log Facts 1.n = b log b n (definition) 2.log b (xy)=log b x + log b y 3.log b a n = nlog b a 4.log b x = log c x / log c b 5.log b (1/a) = -log b a 6.log b a = 1/(log a b) 7.a log b c = c log b a if b > 1, then log b n is strictly increasing.

17 More About Logs A polylogarithm is just

18 Factorial

19 More About Monotonically Increasing Functions

20 Bounding Functions We are more interested in finding upper and lower bounds on functions that describe the running times of algorithms, rather than finding the exact function. Also, we are only interested in considering large inputs: everything is fast for small inputs. So we want asymptotic bounds. Finally, we are willing to neglect constant factors when bounding. They are tedious to compute, and are often hardware-dependent anyway.

21 Example

22 Notation for Function Bounds

23 Big-Oh Facts It denotes an upper bound, not necessarily a tight bound. Thus, The “=” is misleading. E.g is meaningless. Transitivity:

24 Examples We’ve seen that 3n + 8 = O(n). Is 10n = O(3n + 8)? Yes: choose c = 10, n 0 = 1: 10n  n  + 80

25 More Examples 2n 2 + 5n - 8 = O(n 2 )? Yes: 2n 2 + 5n - 8  cn 2  n 2 : 2 + 5/n - 8/n 2  c Choose c = 3; subtracting 2: 5/n - 8/n 2  Choose n o = 5

26 More Examples

27 Lower Bound Notation

28 “Tight” Bound Notation

29 More Facts

30 Examples

31 Another Upper-Bound Notation

32 Functions and Bounds

33 Logarithms

34 Polynomials

35 Comparing Functions