Lecture aid 1 Devon M. Simmonds University of North Carolina, Wilmington CSC231 Data Structures.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms1 Running Time Pseudo-Code Analysis of Algorithms Asymptotic Notation Asymptotic Analysis Mathematical facts COMP-2001 L4&5 Portions.
Advertisements

© 2004 Goodrich, Tamassia 1 Lecture 01 Algorithm Analysis Topics Basic concepts Theoretical Analysis Concept of big-oh Choose lower order algorithms Relatives.
Analysis of Algorithms Algorithm Input Output. Analysis of Algorithms2 Outline and Reading Running time (§1.1) Pseudo-code (§1.1) Counting primitive operations.
Analysis of Algorithms1 CS5302 Data Structures and Algorithms Lecturer: Lusheng Wang Office: Y6416 Phone:
Analysis of Algorithms (Chapter 4)
Analysis of Algorithms1 Estimate the running time Estimate the memory space required. Time and space depend on the input size.
Analysis of Algorithms
Analysis of Algorithms (pt 2) (Chapter 4) COMP53 Oct 3, 2007.
Fall 2006CSC311: Data Structures1 Chapter 4 Analysis Tools Objectives –Experiment analysis of algorithms and limitations –Theoretical Analysis of algorithms.
The Seven Functions. Analysis of Algorithms. Simple Justification Techniques. 2 CPSC 3200 University of Tennessee at Chattanooga – Summer Goodrich,
Analysis of Algorithms1 CS5302 Data Structures and Algorithms Lecturer: Lusheng Wang Office: Y6416 Phone:
PSU CS 311 – Algorithm Design and Analysis Dr. Mohamed Tounsi 1 CS 311 Design and Algorithms Analysis Dr. Mohamed Tounsi
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
Algorithm/Running Time Analysis. Running Time Why do we need to analyze the running time of a program? Option 1: Run the program and time it –Why is this.
CSE 373 Data Structures and Algorithms Lecture 4: Asymptotic Analysis II / Math Review.
CS2210 Data Structures and Algorithms Lecture 2:
Asymptotic Notations Iterative Algorithms and their analysis
Analysis of Algorithms Algorithm Input Output © 2014 Goodrich, Tamassia, Goldwasser1Analysis of Algorithms Presentation for use with the textbook Data.
Analysis of Algorithms Lecture 2
Analysis of Algorithms
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
CSCE 3110 Data Structures & Algorithm Analysis Rada Mihalcea Algorithm Analysis II Reading: Weiss, chap. 2.
Introduction Data Structures & Algorithm Data Structures & Algorithm.
1 Big-Oh Notation CS 105 Introduction to Data Structures and Algorithms.
Analysis Tools Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
Analysis of Algorithms
Analysis of Algorithms1 The Goal of the Course Design “good” data structures and algorithms Data structure is a systematic way of organizing and accessing.
Data Structures Lecture 8 Fang Yu Department of Management Information Systems National Chengchi University Fall 2010.
Computer Science 212 Title: Data Structures and Algorithms
Analysis of Algorithms1 Running Time Pseudo-Code Analysis of Algorithms Asymptotic Notation Asymptotic Analysis Mathematical facts.
Asymptotic Analysis-Ch. 3
1 Dr. J. Michael Moore Data Structures and Algorithms CSCE 221 Adapted from slides provided with the textbook, Nancy Amato, and Scott Schaefer.
Analysis of Algorithms [ Section 4.1 ] Examples of functions important in CS: the constant function:f(n) =
Dr. Alagoz CHAPTER 2 Analysis of Algorithms Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of.
Zeinab EidAlgorithm Analysis1 Chapter 4 Analysis Tools.
COMP 2402/2002 Abstract Data Types and Algorithms Prof: Office: Office hours: Eduardo Mesa HP 5347 Tuesday and Thursday 4:30pm.
CSC401 – Analysis of Algorithms Lecture Notes 2 Asymptotic Analysis Objectives: Mathematics foundation for algorithm analysis Amortization analysis techniques.
Introduction to Analysis of Algorithms CS342 S2004.
Analysis of Algorithms Algorithm Input Output © 2010 Goodrich, Tamassia1Analysis of Algorithms.
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.
Analysis of algorithms. What are we going to learn? Need to say that some algorithms are “better” than others Criteria for evaluation Structure of programs.
CSC Devon M. Simmonds University of North Carolina, Wilmington CSC231 Data Structures.
CSE 373: Data Structures and Algorithms Lecture 4: Math Review/Asymptotic Analysis II 1.
DR. Gatot F. Hertono, MSc. Design and Analysis of ALGORITHM (Session 2)
Lecture 4 Jianjun Hu Department of Computer Science and Engineerintg University of South Carolina CSCE350 Algorithms and Data Structure.
Announcement We will have a 10 minutes Quiz on Feb. 4 at the end of the lecture. The quiz is about Big O notation. The weight of this quiz is 3% (please.
1 COMP9024: Data Structures and Algorithms Week Two: Analysis of Algorithms Hui Wu Session 2, 2014
Analysis of Algorithms Algorithm Input Output © 2014 Goodrich, Tamassia, Goldwasser1Analysis of Algorithms Presentation for use with the textbook Data.
(Complexity) Analysis of Algorithms Algorithm Input Output 1Analysis of Algorithms.
Analysis of Algorithms
Analysis of Algorithms
COMP9024: Data Structures and Algorithms
COMP9024: Data Structures and Algorithms
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Analysis of Algorithms
COMP9024: Data Structures and Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Advanced Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Presentation transcript:

Lecture aid 1 Devon M. Simmonds University of North Carolina, Wilmington CSC231 Data Structures

Lecture aid Math Review: logarithmic functions

Lecture aid 3 properties of exponentials: a (b+c) = a b a c a bc = (a b ) c a b /a c = a (b-c) b = a log a b b c = a c*log a b properties of logarithms: log b (xy) = log b x + log b y log b (x/y) = log b x - log b y log b x a = alog b x log b a = log x a/log x b Math you need to Review

Lecture aid Logarithmic/Exponential Problems. Evaluate and/or simplify.  2 a =8  2 a =1024  2 a = n 2  log 8 32  2 log 4 9  log 12  2 log 9  == 2 12  == 2 7  3 15 /3 10

Lecture aid 5 Asymptotic Notation Big-Oh f(n) is O(g(n)) if f(n) is asymptotically less than or equal to g(n)

Lecture aid Big-Oh Growth Rate f(N) = O(g(N)) iff there are positive constants c and n 0 such that f(N)  c g(N) when N  n 0 – The growth rate of f(N) is less than or equal to the growth rate of g(N) – g(N) is an upper bound on f(N) – f(N) grows no faster than g(N) for “large” N

Lecture aid Big Oh: more examples N 2 / 2 – 3N = O(N 2 ) iff ∃ c, n 0 > 0 such that N 2 / 2 – 3N n 0 Proof N 2 / 2 – 3N <= N 2 – 3N (because N 2 / 2 is less than N 2 ) 0) = O(N 2 ) when c = 1 and n 0 = 1 NN2N2 N 2 /2-3N

Lecture aid Big Oh: more examples N 2 + 3N = O(N 2 ) iff ∃ c, n 0 > 0 such that N 2 + 3N = n 0 Proof 3n = 3, so N 2 + 3n = 3 So N 2 + 3n < 2N 2 = O(N 2 ) where c = 2 and n 0 = 3 NN2N2 N 2 +3N

Lecture aid Big Oh: more examples 7N N + 3 = O(N 2 ) = O(N 3 ) Proof 10N and some c > 0 i.e, 10N , c >= 1 So, 7N N = 8N 2 = O(N 2 ) ∀ n > 10, c >= 8 NN2N2 10N

Lecture aid Big Oh: more examples Prove the following 7N N + 3 = O(N 3 ) N N N = O(N 3 )

Lecture aid Big Oh: more examples log 10 N = O(log 2 N) = O(log N) Proof: log 10 N = log 2 N / log 2 10 = log 2 N / 3.32 = 1, c >= 1 = O(log 2 N) = O(log N) since log 2 N = log k N / log k 2 = O(log k N)

Lecture aid Big Oh: more examples log N + N = O(?)

Lecture aid Big Oh: more examples N 2 / 2 – 3N = O(N 2 ) 1 + 4N = O(N) 7N N + 3 = O(N 2 ) = O(N 3 ) log 10 N = log 2 N / log 2 10 = O(log 2 N) = O(log N) sin N = O(1); 10 = O(1), = O(1) log N + N = O(?) log k N = O(N) for any constant k N = O(2 N ), but 2 N is not O(N) 2 10N is not O(2 N )

Lecture aid 14 Computing Prefix Averages Asymptotic analysis with two algorithms for prefix averages The i -th prefix average of an array X is average of the first (i  1) elements of X: A[i]  X[0]  X[1]  …  X[i])/(i+1) Computing the array A of prefix averages of another array X has applications to financial analysis

Lecture aid 15 A Prefix Averages Algorithm Algorithm prefixAverages1(X) Input array X of n integers Output array A of prefix averages of X A  new array of n integers for i  0 to n  1 do s  X[0] for j  1 to i do s  s  X[j] A[i]  s  (i  1) return A Algorithm prefixAverages2 runs in O(?) time

Lecture aid 16 Another Prefix Averages Algorithm Algorithm prefixAverages2(X) Input array X of n integers Output array A of prefix averages of X A  new array of n integers s  0 for i  0 to n  1 do s  s  X[i] A[i]  s  (i  1) return A Algorithm prefixAverages2 runs in O(?) time

Lecture aid 17 ______________________ Devon M. Simmonds Computer Science Department University of North Carolina Wilmington _____________________________________________________________ Qu es ti ons? Reading from course text: