Lecture 13: Cost of Sorts CS150: Computer Science

Slides:



Advertisements
Similar presentations
BY Lecturer: Aisha Dawood. The notations we use to describe the asymptotic running time of an algorithm are defined in terms of functions whose domains.
Advertisements

Program Efficiency & Complexity Analysis
Class 21: Imperative Programming University of Virginia cs1120 David Evans.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 13: Of On and Off Grounds Sorting.
 The running time of an algorithm as input size approaches infinity is called the asymptotic running time  We study different notations for asymptotic.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 16: Quicker Sorting.
Asymptotic Growth Rate
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 14: Asymptotic Growth.
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
DATA STRUCTURES AND ALGORITHMS Lecture Notes 1 Prepared by İnanç TAHRALI.
Algorithm analysis and design Introduction to Algorithms week1
Asymptotic Notations Iterative Algorithms and their analysis
David Evans Class 12: Quickest Sorting CS150: Computer Science University of Virginia Computer Science Rose Bush by Jacintha.
Algorithmic Complexity: Complexity Analysis of Time Complexity Complexities Nate the Great.
David Evans Class 13: Quicksort, Problems and Procedures CS150: Computer Science University of Virginia Computer Science.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 12: Decrypting Work Circle Fractal.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 2: Orders of Growth
Asymptotic Analysis-Ch. 3
Asymptotic Notation (O, Ω, )
David Evans CS200: Computer Science University of Virginia Computer Science Class 17: Mutation M. C. Escher, Day and Night.
David Evans Class 20: Quick Sorting CS200: Computer Science University of Virginia Computer Science Queen’s University,
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 12: Something about Sneezewort From.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 10: Puzzling Pegboards.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 3: Levels of Abstraction
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Asymptotic Growth Rates  Themes  Analyzing the cost of programs  Ignoring constants and Big-Oh  Recurrence Relations & Sums  Divide and Conquer 
Time Complexity of Algorithms
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 12: QuickSorting Queen’s University,
David Evans CS200: Computer Science University of Virginia Computer Science Class 16: Mutation M. C. Escher, Day and Night.
COP 3530 Spring2012 Data Structures & Algorithms Discussion Session Week 5.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 9: Of On and Off Grounds Sorting Coffee.
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.
Lecture aid 1 Devon M. Simmonds University of North Carolina, Wilmington CSC231 Data Structures.
Algorithms Lecture #05 Uzair Ishtiaq. Asymptotic Notation.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 14: P = NP?
1 Section 5.6 Comparing Rates of Growth We often need to compare functions ƒ and g to see whether ƒ(n) and g(n) are about the same or whether one grows.
Comparing Functions. Notes on Notation N = {0,1,2,3,... } N + = {1,2,3,4,... } R = Set of Reals R + = Set of Positive Reals R * = R + U {0}
Mathematical Foundations (Growth Functions) Neelima Gupta Department of Computer Science University of Delhi people.du.ac.in/~ngupta.
Lecture 13: Quicksorting CS200: Computer Science
Asymptotic Analysis.
Introduction to Algorithms
Lecture 7: List Recursion CS200: Computer Science
Growth of functions CSC317.
Lecture 8: Recursion Practice CS200: Computer Science
Lecture 16: Quickest Sorting CS150: Computer Science
Lecture 6: Programming with Data CS150: Computer Science
Class 14: Intractable Problems CS150: Computer Science
Lecture 11: All Sorts CS200: Computer Science University of Virginia
David Evans Lecture 9: The Great Lambda Tree of Infinite Knowledge and Ultimate Power CS200: Computer Science University.
Asymptotic Growth Rate
Asymptotic Analysis.
Fundamentals of Algorithms MCS - 2 Lecture # 9
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
Lecture 22: P = NP? CS200: Computer Science University of Virginia
Lecture 10: Quicker Sorting CS150: Computer Science
Advanced Analysis of Algorithms
Chapter 2.
Lecture 9: The Great Lambda Tree of Knowledge and Power
Cs1120 Fall 2009 David Evans Lecture 10: Fracturing Fractals cs1120 Fall 2009 David Evans
Lecture 15: Quicker Sorting CS150: Computer Science
Algorithm Analysis T(n) O() Growth Rates 5/21/2019 CS 303 – Big ‘Oh’
Lecture 11: Sorting Grounds and Bubbles
Algorithms CSCI 235, Spring 2019 Lecture 3 Asymptotic Analysis
Advanced Analysis of Algorithms
Analysis of Algorithms Big-Omega and Big-Theta
Big-O & Asymptotic Analysis
Big Omega, Theta Defn: T(N) = (g(N)) if there are positive constants c and n0 such that T(N)  c g(N) for all N  n0 . Lingo: “T(N) grows no slower than.
Lecture 8: Recursing Lists CS150: Computer Science
Presentation transcript:

David Evans http://www.cs.virginia.edu/evans Lecture 13: Cost of Sorts CS150: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans

Menu PS3, Question 4 Operators for Measuring Growth Sorting

Sorting Cost (define (sort lst cf) (if (null? lst) lst (let ((best (find-best lst cf))) (cons best (sort (delete lst best) cf))))) (define (find-best lst cf) (if (= 1 (length lst)) (car lst) (pick-better cf (car lst) (find-best (cdr lst) cf)))) If we double the length of the list, the amount of work approximately quadruples: there are twice as many applications of find-best, and each one takes twice as long

Growth Notations g  O(f) (“Big-Oh”) g  (f) (“Theta”) g grows no faster than f (upper bound) g  (f) (“Theta”) g grows as fast as f (tight bound) g  (f) (“Omega”) g grows no slower than f (lower bound) Which one would we most like to know?

Meaning of O (“big Oh”) g is in O (f) iff: There are positive constants c and n0 such that g(n) ≤ cf(n) for all n ≥ n0.

O Examples Is n in O (n2)? Is 10n in O (n)? Is n2 in O (n)? g is in O (f) iff there are positive constants c and n0 such that g(n) ≤ cf(n) for all n ≥ n0. Is n in O (n2)? Yes, c = 1 and n0=1 works. Is 10n in O (n)? Yes, c = .09 and n0=1 works. Is n2 in O (n)? No, no matter what c we pick, cn2 > n for big enough n (n > c)

Ω (“Omega”): Lower Bound g is in O (f) iff there are positive constants c and n0 such that g(n) ≤ cf(n) for all n ≥ n0. g is in Ω (f) iff there are positive constants c and n0 such that for all n ≥ n0. g(n) ≥ cf(n)

Charge Read Chapter 6 and 7 of the course book PS4 is due Monday