Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2

Size: px
Start display at page:

Download "Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2"

Transcription

1 Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2

2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula for running time of recursive algorithm math help: math. induction Asymptotic notations Algorithm running time classes: P, NP 2

3 Last class Review some algorithms learned in previous classes idea => pseudocode => implementation Correctness of sorting algorithms: insertion sort: gradually expand the sorted sub array/list bubble sort: bubble largest number to the right, also expand sorted sub array/list Algorithm time efficiency: via measurement: implement & instrument the code, run it in a computer 3

4 Example (Fib1: recursive) n T(n)ofFib1 F(n) 10 3e e Time (in seconds) 12 4e e e e e e e n Running time seems to grows exponentially as n increases How long does it take to Calculate F(100)?

5 Example (Fib2: iterative) 10 1e e e e e e e e e-06 Time (in seconds) n Increase very slowly as n increases 44 5

6 Take-away It s possible to perform model-fitting to find out T(n): running time of the algorithms given input size Pros of measurement based studies? Cons: time consuming, maybe too late Does not explain why? 6

7 Analytic approach Is it possible to find out how running time grows when input size grows, analytically? Does running time stay constant, increase linearly, logarithmically, quadratically, exponentially? Yes: analyze pseudocode/code, calculate total number of steps in terms of input size, and study its order of growth results are general: not specific to language, run time system, caching effect, other processes sharing computer shed light on effects of larger problem size, faster CPU, 7

8 Running time analysis Given an algorithm in pseudocode or actual program When the input size is n, how many total number of computer steps are executed? Size of input: size of an array, polynomial degree, # of elements in a matrix, vertices and edges in a graph, or # of bits in the binary representation of input Computer steps: arithmetic operations, data movement, control, decision making (if, while), comparison, each step take a constant amount of time Ignore: overhead of function calls (call stack frame allocation, passing parameters, and return values) 8

9 Let T(n) be number of computer steps needed to compute fib1(n) T(0)=1: when n=0, first step is executed T(1)=2: when n=1, first two steps are executed For n >1, T(n)=T(n-1)+T(n-2)+3: first two steps are executed, fib1(n-1) is called (with T(n-1) steps), fib1(n-2) is called (T(n-2) steps), return values are added (1 step) Can you see that T(n) > F n? How big is T(n)? Case Studies: Fib1(n) 9

10 Let T(n) be number of computer steps to compute fib1(n) T(0)=1 T(1)=2 T(n)=T(n-1)+T(n-2)+3, n>1 Analyze running time of recursive algorithm first, write a recursive formula for its running time then, recursive formula => closed formula, asymptotic result How fast does T(n) grow? Can you see that T(n) > F n? How big is T(n)? Running Time analysis 10

11 Mathematical Induction F0=0, F1=1, Fn=Fn-1+Fn-2 We will show that Fn >= 2 0.5n, for n >=6 using strong mathematical induction technique Intuition of basic mathematical induction it s like Domino effect if one push 1st card, all cards fall because 1) 1st card is pushed down 2) every card is close to next card, so that when one card falls, next one falls 11

12 Mathematical Induction Sometimes, we needs the multiple previous cards to knock down next card Intuition of strong mathematical induction it s like Domino effect: if one push first two cards, all cards fall because the weights of two cards falling down knock down the next card Generalization: 2 => k 12

13 Fibonacci numbers F0=0, F1=1, Fn=Fn-1+Fn-2 show that for all integer n >=6 using strong mathematical induction basis step: show it s true when n=6, 7 inductive step: show if it s true for n=k-1, k, then it s true for k+1 given, F F k 2 k k 1 2 k F k+1 = F k 1 + F k 2 k 1 2 k k k 2 =2 2 k 1 2 =2 1+ k 1 2 =2 k

14 Fibonacci numbers F0=0, F1=1, Fn=Fn-1+Fn-2 Fn is lower bounded by F n 2 n 2 =2 0.5n In fact, there is a tighter lower bound n Recall T(n): number of computer steps to compute fib1(n), T(0)=1 T(1)=2 T(n)=T(n-1)+T(n-2)+3, n> n T (n) >F n n 14

15 Exponential running time Running time of Fib1: T(n)> n Running time of Fib1 is exponential in n calculate F 200, it takes at least computer steps On NEC Earth Simulator (fastest computer ) Executes 40 trillion (10 12 ) steps per second, 40 teraflots Assuming each step takes same amount of time as a floating point operation Time to calculate F 200: at least 2 92 seconds, i.e., 1.57x10 20 years Can we throw more computing power to the problem? Moore s law: computer speeds double about every 18 months (or 2 years according to newer version) 15

16 Exponential algorithms Moore s law (computer speeds double about every two years) can sustain for 4-5 more years 16

17 Exponential running time Running time of Fib1: T(n)> n = n Moore s law: computer speeds double about every 18 months (or 2 years according to newer version) If it takes fastest CPU of this year 6 minutes to calculate F50, fastest CPU in two years from today can calculate F52 in 6 minutes Algorithms with exponential running time are not efficient, not scalable 17

18 Fastest Supercomputer June 2017 ranking Sunway TaihuLight, 93 petaflopts Tianhe-2 (milky way-2), 33.9 petaflops Cray XC50, Swiss, 19.6 petaflops Titan, Cray XK7, US, 17.6 petaflopts Petaflop: one thousand million million (10 15 ) floating-point operations per second Need parallel algorithms to take full advantage of these computers 18

19 Big numbers 19

20 Can we do better? Draw recursive function call tree for fib1(5) Observation: wasteful repeated calculation Idea: Store solutions to subproblems in array (key of Dynamic Programming) 20

21 Running time fib2(n) Analyze running time of iterative (non-recursive) algorithm: T(n)=1 // if n=0 return 0 +n // create an array of f[0 n] +2 // f[0]=0, f[1]=1 +(n-1) // for loop: repeated for n-1 times = 2n+2 T(n) is a linear function of n, or fib2(n) has linear running time 21

22 Alternatively How long does it take for fib2(n) finish? T(n)= n+2*60+(n-1)*800=1000n+320 // in unit of us Again: T(n) is a linear function of n Estimation based upon CPU: takes 1000us, takes 200n us each assignment takes 60us addition and assignment takes 800us Constants are not important: different on different computers System effects (caching, OS scheduling) makes it pointless to do such fine-grained analysis anyway Algorithm analysis focuses on how running time grows as problem size grows (constant, linear, quadratic, exponential?) not the actual real world time 22

23 Summary: Running time analysis Given an algorithm in pseudocode or actual program When the input size is n, how many total number of computer steps are executed? Size of input: size of an array, polynomial degree, # of elements in a matrix, vertices and edges in a graph, or # of bits in the binary representation of input Computer steps: arithmetic operations, data movement, control, decision making (if, while), comparison, Ignore: each step take a constant amount of time Overhead of function calls (call stack frame allocation, passing parameters, and return values) Different execution time for different steps 23

24 Time for exercises/examples 1. Reading algorithms in pseudocode 2. Writing algorithms in pseudocode 3. Analyzing algorithms 24

25 Algorithm Analysis: Example What s the running time of MIN? Algorithm/Function.: MIN (a[1 n]) input: an array of numbers a[1 n] output: the minimum number among a[1 n] m = a[1] for i=2 to n: if a[i] < m: m = a[i] return m How do we measure the size of input for this algorithm? How many computer steps when the input s size is n? 25

26 Algorithm Analysis: bubble sort Algorithm/Function.: bubblesort (a[1 n]) input: a list of numbers a[1 n] output: a sorted version of this list for endp=n to 2: for i=1 to endp-1: if a[i] > a[i+1]: swap (a[i], a[i+1]) return a How do you choose to measure the size of input? length of list a, i.e., n the longer the input list, the longer it takes to sort it Problem instance: a particular input to the algorithm e.g., a[1 6]={1, 4, 6, 2, 7, 3} e.g., a[1 6]={1, 4, 5, 6, 7, 9} 26

27 Algorithm Analysis: bubble sort Algorithm/Function.: bubblesort (a[1 n]) input: an array of numbers a[1 n] output: a sorted version of this array for endp=n to 2: for i=1 to endp-1: if a[i] > a[i+1]: swap (a[i], a[i+1]) return a a compute step endp=n: inner loop (for j=1 to endp-1) repeats for n-1 times endp=n-1: inner loop repeats for n-2 times endp=n-2: inner loop repeats for n-3 times endp=2: inner loop repeats for 1 times Total # of steps: T(n) = (n-1)+(n-2)+(n-3)

28 How big is T(n)? T(n) = (n-1)+(n-2)+(n-3)+ +1 Can you write big sigma notation for T(n)? Can you write simplified formula for T(n)? Can you prove the above using math. induction? 1) when n=2, left hand size =1, right hand size is 2) if the equation is true for n=k, then it s also true for n=k+1 28

29 Algorithm Analysis: Binary Search Algorithm/Function.: search (a[l R], value) input: a list of numbers a[l R] sorted in ascending order, a number value output: the index of value in list a (if value is in it), or -1 if not found if (L>R): return -1 m = (L+R)/2 if (a[m]==value): return m else: if (a[m]>value): return search (a[l m-1], value) else: return search (a[m+1 R], value) What s the size of input in this algorithm? length of list a[l R] 29

30 Algorithm Analysis: Binary Search Algorithm/Function.: search (a[l R], value) input: a list of numbers a[l R] sorted in ascending order, a number value output: the index of value in list a (if value is in it), or -1 if not found if (L>R): return -1 m = (L+R)/2 if (a[m]==value): return m else: if (a[m]>value): return search (a[l m-1], value) else: return search (a[m+1 R], value) Let T(n) be number of steps to search an list of size n best case (value is in middle point), T(n)=3 worst case (when value is not in list) provides an upper bound 30

31 Algorithm Analysis: Binary Search Algorithm/Function.: search (a[l R], value) input: a list of numbers a[l R] sorted in ascending order, a number value output: the index of value in list a (if value is in it), or -1 if not found if (L>R): return -1 m = (L+R)/2 if (a[m]==value): return m else: if (a[m]>value): return search (a[l m-1], value) else: return search (a[m+1 R], value) Let T(n) be number of steps to search an list of size n in worst case T(0)=1 //base case, when L>R T(n)=3+T(n/2) //general case, reduce problem size by half Next chapter: master theorem solving T(n)=log2n 31

32 mini-summary Running time analysis identifying input size n counting, and recursive formula: number of steps in terms of n Chapter 2: Solving recursive formula Next: Asymptotic running time 32

33 Order (Growth Rate) of functions Growth rate: How fast f(x) increases as x increases slope (derivative) f(x + x) f(x) x f(x)=2x: constant growth rate (slope is 2) f(x) =2 x : growth rate increases as x increases (see figure above) f(x) =log 2 x: growth rate decreases as x increases 33

34 Order (Growth Rate) of functions Asymptotic Growth rate: growth rate of function when slope (derivative) when x is very big The larger asym. growth rate, the larger f(x) when x 1 e.g., f(x)=2x: asymptotic growth rate is 2 : very big f(x) =2 x x 1 (Asymptotic) Growth rate of functions of n (from low to high): log(n) < n < nlog(n) < n 2 < n 3 < n 4 <.< 1.5 n < 2 n < 3 n 34

35 Compare two running times Two sorting algorithms: yours: 50nlog 2 n your friend: 2n 2 Which one is better (for large program size)? Compare ratio when n is large 50nlog 2 n 2n 2 = 25log 2n n 0, when n 0 For large n, running time of your algorithm is much smaller than that of your friends. 35

36 Rules of thumb if We say g(n) dominates f(n) n a dominates n b, if a>b e.g., n 2 dominates n any exponential dominates any polynomials e.g., 1.1 n dominates n 20 any polynomial dominates any logarithm n dominates logn 2 f(n) g(n) 0, when n 1 36

37 Algorithm Efficiency vs. Speed E.g.: sorting n numbers Friend s computer = 10 9 instructions/second Friend s algorithm = 2n 2 computer steps Your computer = 10 7 instructions/second Your algorithm = 50nlog(n) computer steps To sort n=10 6 numbers, Your friend: You: Your algorithm finishes 20 times faster More importantly, the ratio becomes larger with larger n 37

38 Compare Growth Rate of functions(2) Two sorting algorithms: yours: 2n n your friend: 2n 2 Which one is better (for large arrays)? Compare ratio when n is large 2n n 2n 2 =1+ 100n 2n 2 =1+50 n 1, when n 1 They are same In general, the lower order term can be dropped. 38

39 Compare Growth Rate of functions(3) Two sorting algorithms: yours: 100n 2 your friend: n 2 Your friend s wins. Ratio of the two functions: 100n 2 n 2 = 100, as n 1 The ratio is a constant as n increase. => They scale in the same way. Your alg. always takes 100x time, no matter how big n is. 39

40 Focus on Asymptotic Growth Rate In answering How fast T(n) grows as n grows?, leave out lower-order terms constant coefficient: not reliable info. (arbitrarily counts # of computer steps), and hardware difference makes them not important Note: you still want to optimize your code to bring down constant coefficients. It s only that they don t affect asymptotic growth rate for example: bubble sort executes steps to sort a list of n elements We say bubble sort s running time is quadratic in n, or T(n)=n 2. 40

41 Big-O notation Let f(n) and g(n) be two functions from positive integers to positive reals. f=o(g) means: f grows no faster than g, g is asymptotic upper bound of f(n) f = O(g) if there is a constant c>0 such that for all n, or Most books use notations, where O(g) denotes the set of all functions T(n) for which there is a constant c>0, such that In reference textbook (CLR), for all n>n 0, f(n) apple c g(n) 41

42 Big-O notations: Example f=o(g) if there is a constant c>0 such that for all n, e.g., f(n)=100n 2, g(n)=n 3 so f(n)=o(g(n)), or 100n 2 =O(n 3 ) Exercise: 100n 2 +8n=O(n 2 ) nlog(n)=o(n 2 ) 2 n = O(3 n ) 42

43 Big-Ω notations Let f(n) and g(n) be two functions from positive inters to positive reals. f=ω(g) means: f grows no slower than g, g is asymptotic lower bound of f f = Ω(g) if and only if g=o(f) or, if and only if there is a constant c, such that for all n, Equivalent def in CLR: there is a constant c, such that for all n>n0, 43

44 Big-Ω notations f=ω(g) means: f grows no slower than g, g is asymptotic lower bound of f f = Ω(g) if and only if g=o(f) or, if and only if there is a constant c, such that for all n, e.g., f(n)=100n 2, g(n)=n so f(n)=ω(g(n)), or 100n 2 =Ω(n) Exercise: show 100n 2 +8n=Ω(n 2 ) and 2 n =Ω(n 8 ) 44

45 Big- notations f = (g) means: f grows no slower and no faster than g, f grows at same rate as g asymptotically f = (g) if and only if f = O(g) and f = (g) i.e., there are constants c1, c2>0, s.t., c 1 g(n) apple f(n) apple c 2 g(n), for any n Function f can be sandwiched between g by two constant factors 45

46 Big- notations Show that log 2 n = (log 10 n) 46

47 mini-summary in analyzing running time of algorithms, what s important is scalability (perform well for large input) therefore, constants are not important (counting if.. then as 1 or 2 steps does not matter) focus on higher order which dominates lower order parts a three-level nested loop dominates a single-level loop In algorithm implementation, constants matters 47

48 Typical Running Time Functions 1 (constant running time): Instructions are executed once or a few times log(n) (logarithmic), e.g., binary search A big problem is solved by cutting original problem in smaller sizes, by a constant fraction at each step n (linear): linear search A small amount of processing is done on each input element n log(n): merge sort A problem is solved by dividing it into smaller problems, solving them independently and combining the solution 48

49 Typical Running Time Functions n 2 (quadratic): bubble sort Typical for algorithms that process all pairs of data items (double nested loops) n 3 (cubic) Processing of triples of data (triple nested loops) n K (polynomial) n (exponential): Fib1 2 n (exponential): Few exponential algorithms are appropriate for practical use 3 n (exponential), 49

50 Review of logarithmic functions Definition Rules Applications to CS 50

51 NP-Completeness An problem that has polynomial running time algorithm is considered tractable (feasible to be solved efficiently) Not all problems are tractable Some problems cannot be solved by any computer no matter how much time is provided (Turing s Halting problem) such problems are called undecidable Some problems can be solved in exponential time, but have no known polynomial time algorithm Can we tell if a problem can be solved in polynomial time? NP, NP-complete, NP-hard 51

52 Summary This class focused on algorithm running time analysis start with running time function, expressing number of computer steps in terms of input size Focus on very large problem size, i.e., asymptotic running time big-o notations => focus on dominating terms in running time function Constant, linear, polynomial, exponential time algorithms NP, NP complete problem 52

53 Coming up? Algorithm analysis is only one aspect of the class We will look at different algorithms design paradigm, using problems from a wide range of domain (number, encryption, sorting, searching, graph, ) 53

54 Readings Chapter 1 54

Computer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2

Computer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2 Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula

More information

Algorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang

Algorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Algorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Last class Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive

More information

CS173 Running Time and Big-O. Tandy Warnow

CS173 Running Time and Big-O. Tandy Warnow CS173 Running Time and Big-O Tandy Warnow CS 173 Running Times and Big-O analysis Tandy Warnow Today s material We will cover: Running time analysis Review of running time analysis of Bubblesort Review

More information

csci 210: Data Structures Program Analysis

csci 210: Data Structures Program Analysis csci 210: Data Structures Program Analysis Summary Topics commonly used functions analysis of algorithms experimental asymptotic notation asymptotic analysis big-o big-omega big-theta READING: GT textbook

More information

csci 210: Data Structures Program Analysis

csci 210: Data Structures Program Analysis csci 210: Data Structures Program Analysis 1 Summary Summary analysis of algorithms asymptotic analysis big-o big-omega big-theta asymptotic notation commonly used functions discrete math refresher READING:

More information

CSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms

CSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms (2017F) Lecture4: Analysis of Algorithms Daijin Kim CSE, POSTECH dkim@postech.ac.kr Running Time Most algorithms transform input objects into output objects. The running time of an algorithm typically

More information

Analysis of Algorithms

Analysis of Algorithms Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Analysis of Algorithms Input Algorithm Analysis

More information

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

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

Lecture 1 - Preliminaries

Lecture 1 - Preliminaries Advanced Algorithms Floriano Zini Free University of Bozen-Bolzano Faculty of Computer Science Academic Year 2013-2014 Lecture 1 - Preliminaries 1 Typography vs algorithms Johann Gutenberg (c. 1398 February

More information

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

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

CSCE 222 Discrete Structures for Computing

CSCE 222 Discrete Structures for Computing CSCE 222 Discrete Structures for Computing Algorithms Dr. Philip C. Ritchey Introduction An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem.

More information

Mathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review:

Mathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review: Mathematical Background Mathematical Background CSE 373 Data Structures Today, we will review: Logs and eponents Series Recursion Motivation for Algorithm Analysis 5 January 007 CSE 373 - Math Background

More information

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

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

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

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions

More information

Ch01. Analysis of Algorithms

Ch01. Analysis of Algorithms Ch01. Analysis of Algorithms Input Algorithm Output Acknowledgement: Parts of slides in this presentation come from the materials accompanying the textbook Algorithm Design and Applications, by M. T. Goodrich

More information

Algorithm. Executing the Max algorithm. Algorithm and Growth of Functions Benchaporn Jantarakongkul. (algorithm) ก ก. : ก {a i }=a 1,,a n a i N,

Algorithm. Executing the Max algorithm. Algorithm and Growth of Functions Benchaporn Jantarakongkul. (algorithm) ก ก. : ก {a i }=a 1,,a n a i N, Algorithm and Growth of Functions Benchaporn Jantarakongkul 1 Algorithm (algorithm) ก ก ก ก ก : ก {a i }=a 1,,a n a i N, ก ก : 1. ก v ( v ก ก ก ก ) ก ก a 1 2. ก a i 3. a i >v, ก v ก a i 4. 2. 3. ก ก ก

More information

Asymptotic Running Time of Algorithms

Asymptotic Running Time of Algorithms Asymptotic Complexity: leading term analysis Asymptotic Running Time of Algorithms Comparing searching and sorting algorithms so far: Count worst-case of comparisons as function of array size. Drop lower-order

More information

Growth of Functions (CLRS 2.3,3)

Growth of Functions (CLRS 2.3,3) Growth of Functions (CLRS 2.3,3) 1 Review Last time we discussed running time of algorithms and introduced the RAM model of computation. Best-case running time: the shortest running time for any input

More information

Principles of Algorithm Analysis

Principles of Algorithm Analysis C H A P T E R 3 Principles of Algorithm Analysis 3.1 Computer Programs The design of computer programs requires:- 1. An algorithm that is easy to understand, code and debug. This is the concern of software

More information

Fundamentals of Programming. Efficiency of algorithms November 5, 2017

Fundamentals of Programming. Efficiency of algorithms November 5, 2017 15-112 Fundamentals of Programming Efficiency of algorithms November 5, 2017 Complexity of sorting algorithms Selection Sort Bubble Sort Insertion Sort Efficiency of Algorithms A computer program should

More information

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Lecture 1: Asymptotics, Recurrences, Elementary Sorting Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running

More information

CIS 121. Analysis of Algorithms & Computational Complexity. Slides based on materials provided by Mary Wootters (Stanford University)

CIS 121. Analysis of Algorithms & Computational Complexity. Slides based on materials provided by Mary Wootters (Stanford University) CIS 121 Analysis of Algorithms & Computational Complexity Slides based on materials provided by Mary Wootters (Stanford University) Today Sorting: InsertionSort vs MergeSort Analyzing the correctness of

More information

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 1: Introduction

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 1: Introduction CSE 101 Algorithm Design and Analysis Miles Jones mej016@eng.ucsd.edu Office 4208 CSE Building Lecture 1: Introduction LOGISTICS Book: Algorithms by Dasgupta, Papadimitriou and Vazirani Homework: Due Wednesdays

More information

CS 310 Advanced Data Structures and Algorithms

CS 310 Advanced Data Structures and Algorithms CS 310 Advanced Data Structures and Algorithms Runtime Analysis May 31, 2017 Tong Wang UMass Boston CS 310 May 31, 2017 1 / 37 Topics Weiss chapter 5 What is algorithm analysis Big O, big, big notations

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2 MA008 p.1/36 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/36 Content of lecture 2 Examples Review data structures Data types vs. data

More information

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency Lecture 2 Fundamentals of the Analysis of Algorithm Efficiency 1 Lecture Contents 1. Analysis Framework 2. Asymptotic Notations and Basic Efficiency Classes 3. Mathematical Analysis of Nonrecursive Algorithms

More information

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

Lecture 3. Big-O notation, more recurrences!! Lecture 3 Big-O notation, more recurrences!! Announcements! HW1 is posted! (Due Friday) See Piazza for a list of HW clarifications First recitation section was this morning, there s another tomorrow (same

More information

Ch 01. Analysis of Algorithms

Ch 01. Analysis of Algorithms Ch 01. Analysis of Algorithms Input Algorithm Output Acknowledgement: Parts of slides in this presentation come from the materials accompanying the textbook Algorithm Design and Applications, by M. T.

More information

Algorithms Design & Analysis. Analysis of Algorithm

Algorithms Design & Analysis. Analysis of Algorithm Algorithms Design & Analysis Analysis of Algorithm Review Internship Stable Matching Algorithm 2 Outline Time complexity Computation model Asymptotic notions Recurrence Master theorem 3 The problem of

More information

COMP 382: Reasoning about algorithms

COMP 382: Reasoning about algorithms Fall 2014 Unit 4: Basics of complexity analysis Correctness and efficiency So far, we have talked about correctness and termination of algorithms What about efficiency? Running time of an algorithm For

More information

CS 344 Design and Analysis of Algorithms. Tarek El-Gaaly Course website:

CS 344 Design and Analysis of Algorithms. Tarek El-Gaaly Course website: CS 344 Design and Analysis of Algorithms Tarek El-Gaaly tgaaly@cs.rutgers.edu Course website: www.cs.rutgers.edu/~tgaaly/cs344.html Course Outline Textbook: Algorithms by S. Dasgupta, C.H. Papadimitriou,

More information

Data Structures and Algorithms CSE 465

Data Structures and Algorithms CSE 465 Data Structures and Algorithms CSE 465 LECTURE 3 Asymptotic Notation O-, Ω-, Θ-, o-, ω-notation Divide and Conquer Merge Sort Binary Search Sofya Raskhodnikova and Adam Smith /5/0 Review Questions If input

More information

Analysis of Algorithms

Analysis of Algorithms October 1, 2015 Analysis of Algorithms CS 141, Fall 2015 1 Analysis of Algorithms: Issues Correctness/Optimality Running time ( time complexity ) Memory requirements ( space complexity ) Power I/O utilization

More information

Algorithms and Their Complexity

Algorithms and Their Complexity CSCE 222 Discrete Structures for Computing David Kebo Houngninou Algorithms and Their Complexity Chapter 3 Algorithm An algorithm is a finite sequence of steps that solves a problem. Computational complexity

More information

Advanced Algorithmics (6EAP)

Advanced Algorithmics (6EAP) Advanced Algorithmics (6EAP) MTAT.03.238 Order of growth maths Jaak Vilo 2017 fall Jaak Vilo 1 Program execution on input of size n How many steps/cycles a processor would need to do How to relate algorithm

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms Taking Stock IE170: Algorithms in Systems Engineering: Lecture 3 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 19, 2007 Last Time Lots of funky math Playing

More information

CS1210 Lecture 23 March 8, 2019

CS1210 Lecture 23 March 8, 2019 CS1210 Lecture 23 March 8, 2019 HW5 due today In-discussion exams next week Optional homework assignment next week can be used to replace a score from among HW 1 3. Will be posted some time before Monday

More information

Problem-Solving via Search Lecture 3

Problem-Solving via Search Lecture 3 Lecture 3 What is a search problem? How do search algorithms work and how do we evaluate their performance? 1 Agenda An example task Problem formulation Infrastructure for search algorithms Complexity

More information

Data Structures and Algorithms. Asymptotic notation

Data Structures and Algorithms. Asymptotic notation Data Structures and Algorithms Asymptotic notation Estimating Running Time Algorithm arraymax executes 7n 1 primitive operations in the worst case. Define: a = Time taken by the fastest primitive operation

More information

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

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013 /4/3 Administrative Big O David Kauchak cs3 Spring 3 l Assignment : how d it go? l Assignment : out soon l CLRS code? l Videos Insertion-sort Insertion-sort Does it terminate? /4/3 Insertion-sort Loop

More information

The Time Complexity of an Algorithm

The Time Complexity of an Algorithm Analysis of Algorithms The Time Complexity of an Algorithm Specifies how the running time depends on the size of the input. Purpose To estimate how long a program will run. To estimate the largest input

More information

Data Structures and Algorithms Running time and growth functions January 18, 2018

Data Structures and Algorithms Running time and growth functions January 18, 2018 Data Structures and Algorithms Running time and growth functions January 18, 2018 Measuring Running Time of Algorithms One way to measure the running time of an algorithm is to implement it and then study

More information

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010 Announcements CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Dan Grossman Spring 2010 Project 1 posted Section materials on using Eclipse will be very useful if you have never used

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015 Today Registration should be done. Homework 1 due 11:59pm next Wednesday, April 8 th. Review math

More information

Topic 17. Analysis of Algorithms

Topic 17. Analysis of Algorithms Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm

More information

Running Time Evaluation

Running Time Evaluation Running Time Evaluation Quadratic Vs. Linear Time Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 19 1 Running time 2 Examples 3 Big-Oh, Big-Omega, and Big-Theta Tools 4 Time

More information

The Time Complexity of an Algorithm

The Time Complexity of an Algorithm CSE 3101Z Design and Analysis of Algorithms The Time Complexity of an Algorithm Specifies how the running time depends on the size of the input. Purpose To estimate how long a program will run. To estimate

More information

Computational Complexity

Computational Complexity Computational Complexity S. V. N. Vishwanathan, Pinar Yanardag January 8, 016 1 Computational Complexity: What, Why, and How? Intuitively an algorithm is a well defined computational procedure that takes

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 10, 2018 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. 1 /

More information

CS Analysis of Recursive Algorithms and Brute Force

CS Analysis of Recursive Algorithms and Brute Force CS483-05 Analysis of Recursive Algorithms and Brute Force Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture II: Chapter 2 R. Paul Wiegand George Mason University, Department of Computer Science February 1, 2006 Outline 1 Analysis Framework 2 Asymptotic

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 14, 2019 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. COMP

More information

COMP 9024, Class notes, 11s2, Class 1

COMP 9024, Class notes, 11s2, Class 1 COMP 90, Class notes, 11s, Class 1 John Plaice Sun Jul 31 1::5 EST 011 In this course, you will need to know a bit of mathematics. We cover in today s lecture the basics. Some of this material is covered

More information

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu Analysis of Algorithm Efficiency Dr. Yingwu Zhu Measure Algorithm Efficiency Time efficiency How fast the algorithm runs; amount of time required to accomplish the task Our focus! Space efficiency Amount

More information

3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need?

3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need? 3. Algorithms We will study algorithms to solve many different types of problems such as finding the largest of a sequence of numbers sorting a sequence of numbers finding the shortest path between two

More information

Algorithms 2/6/2018. Algorithms. Enough Mathematical Appetizers! Algorithm Examples. Algorithms. Algorithm Examples. Algorithm Examples

Algorithms 2/6/2018. Algorithms. Enough Mathematical Appetizers! Algorithm Examples. Algorithms. Algorithm Examples. Algorithm Examples Enough Mathematical Appetizers! Algorithms What is an algorithm? Let us look at something more interesting: Algorithms An algorithm is a finite set of precise instructions for performing a computation

More information

Discrete Mathematics CS October 17, 2006

Discrete Mathematics CS October 17, 2006 Discrete Mathematics CS 2610 October 17, 2006 Uncountable sets Theorem: The set of real numbers is uncountable. If a subset of a set is uncountable, then the set is uncountable. The cardinality of a subset

More information

Data Structures and Algorithms Chapter 2

Data Structures and Algorithms Chapter 2 1 Data Structures and Algorithms Chapter 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

What is Performance Analysis?

What is Performance Analysis? 1.2 Basic Concepts What is Performance Analysis? Performance Analysis Space Complexity: - the amount of memory space used by the algorithm Time Complexity - the amount of computing time used by the algorithm

More information

Algorithms (I) Yijia Chen Shanghai Jiaotong University

Algorithms (I) Yijia Chen Shanghai Jiaotong University Algorithms (I) Yijia Chen Shanghai Jiaotong University Instructor and teaching assistants Instructor and teaching assistants Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijia.chen@cs.sjtu.edu.cn

More information

Cpt S 223. School of EECS, WSU

Cpt S 223. School of EECS, WSU Algorithm Analysis 1 Purpose Why bother analyzing code; isn t getting it to work enough? Estimate time and memory in the average case and worst case Identify bottlenecks, i.e., where to reduce time Compare

More information

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt Lecture 3 The Analysis of Recursive Algorithm Efficiency What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency

More information

ASYMPTOTIC COMPLEXITY SEARCHING/SORTING

ASYMPTOTIC COMPLEXITY SEARCHING/SORTING Quotes about loops O! Thou hast damnable iteration and art, indeed, able to corrupt a saint. Shakespeare, Henry IV, Pt I, 1 ii Use not vain repetition, as the heathen do. Matthew V, 48 Your if is the only

More information

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

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0 Asymptotic Notation Asymptotic notation deals with the behaviour of a function in the limit, that is, for sufficiently large values of its parameter. Often, when analysing the run time of an algorithm,

More information

Data Structures. Outline. Introduction. Andres Mendez-Vazquez. December 3, Data Manipulation Examples

Data Structures. Outline. Introduction. Andres Mendez-Vazquez. December 3, Data Manipulation Examples Data Structures Introduction Andres Mendez-Vazquez December 3, 2015 1 / 53 Outline 1 What the Course is About? Data Manipulation Examples 2 What is a Good Algorithm? Sorting Example A Naive Algorithm Counting

More information

How many hours would you estimate that you spent on this assignment?

How many hours would you estimate that you spent on this assignment? The first page of your homework submission must be a cover sheet answering the following questions. Do not leave it until the last minute; it s fine to fill out the cover sheet before you have completely

More information

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016 CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis Hunter Zahn Summer 2016 Today Finish discussing stacks and queues Review math essential to algorithm analysis Proof by

More information

Asymptotic Analysis of Algorithms. Chapter 4

Asymptotic Analysis of Algorithms. Chapter 4 Asymptotic Analysis of Algorithms Chapter 4 Overview Motivation Definition of Running Time Classifying Running Time Asymptotic Notation & Proving Bounds Algorithm Complexity vs Problem Complexity Overview

More information

P, NP, NP-Complete, and NPhard

P, NP, NP-Complete, and NPhard P, NP, NP-Complete, and NPhard Problems Zhenjiang Li 21/09/2011 Outline Algorithm time complicity P and NP problems NP-Complete and NP-Hard problems Algorithm time complicity Outline What is this course

More information

with the size of the input in the limit, as the size of the misused.

with the size of the input in the limit, as the size of the misused. Chapter 3. Growth of Functions Outline Study the asymptotic efficiency of algorithms Give several standard methods for simplifying the asymptotic analysis of algorithms Present several notational conventions

More information

Analysis of Algorithms

Analysis of Algorithms Analysis of Algorithms Section 4.3 Prof. Nathan Wodarz Math 209 - Fall 2008 Contents 1 Analysis of Algorithms 2 1.1 Analysis of Algorithms....................... 2 2 Complexity Analysis 4 2.1 Notation

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Based

More information

Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College

Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College Why analysis? We want to predict how the algorithm will behave (e.g. running time) on arbitrary inputs, and how it will

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents

More information

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

Great Theoretical Ideas in Computer Science. Lecture 7: Introduction to Computational Complexity 15-251 Great Theoretical Ideas in Computer Science Lecture 7: Introduction to Computational Complexity September 20th, 2016 What have we done so far? What will we do next? What have we done so far? > Introduction

More information

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary Complexity Analysis Complexity Theory Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary Output TRUE or FALSE Time and Space

More information

Sorting. Chapter 11. CSE 2011 Prof. J. Elder Last Updated: :11 AM

Sorting. Chapter 11. CSE 2011 Prof. J. Elder Last Updated: :11 AM Sorting Chapter 11-1 - Sorting Ø We have seen the advantage of sorted data representations for a number of applications q Sparse vectors q Maps q Dictionaries Ø Here we consider the problem of how to efficiently

More information

CISC 235: Topic 1. Complexity of Iterative Algorithms

CISC 235: Topic 1. Complexity of Iterative Algorithms CISC 235: Topic 1 Complexity of Iterative Algorithms Outline Complexity Basics Big-Oh Notation Big-Ω and Big-θ Notation Summations Limitations of Big-Oh Analysis 2 Complexity Complexity is the study of

More information

Chapter 0. Prologue. Algorithms (I) Johann Gutenberg. Two ideas changed the world. Decimal system. Al Khwarizmi

Chapter 0. Prologue. Algorithms (I) Johann Gutenberg. Two ideas changed the world. Decimal system. Al Khwarizmi Algorithms (I) Yijia Chen Shanghai Jiaotong University Chapter 0. Prologue Johann Gutenberg Two ideas changed the world Because of the typography, literacy spread, the Dark Ages ended, the human intellect

More information

CS 4407 Algorithms Lecture 2: Growth Functions

CS 4407 Algorithms Lecture 2: Growth Functions CS 4407 Algorithms Lecture 2: Growth Functions Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline Growth Functions Mathematical specification of growth functions

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?

More information

ECE250: Algorithms and Data Structures Analyzing and Designing Algorithms

ECE250: Algorithms and Data Structures Analyzing and Designing Algorithms ECE50: Algorithms and Data Structures Analyzing and Designing Algorithms Ladan Tahvildari, PEng, SMIEEE Associate Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng.

More information

Divide and Conquer Problem Solving Method

Divide and Conquer Problem Solving Method Divide and Conquer Problem Solving Method 1. Problem Instances Let P be a problem that is amenable to the divide and conquer algorithm design method and let P 0, P 1, P 2, be distinct instances of the

More information

Big , and Definition Definition

Big , and Definition Definition Big O, Ω, and Θ Big-O gives us only a one-way comparison; if f is O(g) then g eventually is bigger than f from that point on, but in fact f could be very small in comparison. Example; 3n is O(2 2n ). We

More information

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 14 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/ Lecture 14 Notes Goals for this week Big-O complexity

More information

CS Non-recursive and Recursive Algorithm Analysis

CS Non-recursive and Recursive Algorithm Analysis CS483-04 Non-recursive and Recursive Algorithm Analysis Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/

More information

Define Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 417: Algorithms and Computational Complexity. Winter 2007 Larry Ruzzo

Define Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 417: Algorithms and Computational Complexity. Winter 2007 Larry Ruzzo CSE 417: Algorithms and Computational 2: Analysis Winter 2007 Larry Ruzzo Define Efficiency Runs fast on typical real problem instances Pro: sensible, bottom-line-oriented Con: moving target (diff computers,

More information

Space Complexity of Algorithms

Space Complexity of Algorithms Space Complexity of Algorithms So far we have considered only the time necessary for a computation Sometimes the size of the memory necessary for the computation is more critical. The amount of memory

More information

Algorithms and Data S tructures Structures Complexity Complexit of Algorithms Ulf Leser

Algorithms and Data S tructures Structures Complexity Complexit of Algorithms Ulf Leser Algorithms and Data Structures Complexity of Algorithms Ulf Leser Content of this Lecture Efficiency of Algorithms Machine Model Complexity Examples Multiplication of two binary numbers (unit cost?) Exact

More information

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2 In-Class Soln 1 Let f(n) be an always positive function and let g(n) = f(n) log n. Show that f(n) = o(g(n)) CS 361, Lecture 4 Jared Saia University of New Mexico For any positive constant c, we want to

More information

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

CSC 8301 Design & Analysis of Algorithms: Lower Bounds CSC 8301 Design & Analysis of Algorithms: Lower Bounds Professor Henry Carter Fall 2016 Recap Iterative improvement algorithms take a feasible solution and iteratively improve it until optimized Simplex

More information

CSE 373: Data Structures and Algorithms Pep Talk; Algorithm Analysis. Riley Porter Winter 2017

CSE 373: Data Structures and Algorithms Pep Talk; Algorithm Analysis. Riley Porter Winter 2017 CSE 373: Data Structures and Algorithms Pep Talk; Algorithm Analysis Riley Porter Announcements Op4onal Java Review Sec4on: PAA A102 Tuesday, January 10 th, 3:30-4:30pm. Any materials covered will be posted

More information

Solving Recurrences. Lecture 23 CS2110 Fall 2011

Solving Recurrences. Lecture 23 CS2110 Fall 2011 Solving Recurrences Lecture 23 CS2110 Fall 2011 1 Announcements Makeup Prelim 2 Monday 11/21 7:30-9pm Upson 5130 Please do not discuss the prelim with your classmates! Quiz 4 next Tuesday in class Topics:

More information

Describe an algorithm for finding the smallest integer in a finite sequence of natural numbers.

Describe an algorithm for finding the smallest integer in a finite sequence of natural numbers. Homework #4 Problem One (2.1.2) Determine which characteristics o f an algorithm the following procedures have and which they lack. a) procedure double(n: positive integer) while n > 0 n := 2n Since n

More information

CSE 417: Algorithms and Computational Complexity

CSE 417: Algorithms and Computational Complexity CSE 417: Algorithms and Computational Complexity Lecture 2: Analysis Larry Ruzzo 1 Why big-o: measuring algorithm efficiency outline What s big-o: definition and related concepts Reasoning with big-o:

More information

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

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Lecture 2 More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Announcements Assignment #1 is posted online It is directly related to MCSS which we will be talking about today or Monday. There are

More information

3.1 Asymptotic notation

3.1 Asymptotic notation 3.1 Asymptotic notation The notations we use to describe the asymptotic running time of an algorithm are defined in terms of functions whose domains are the set of natural numbers N = {0, 1, 2,... Such

More information

Asymptotic Algorithm Analysis & Sorting

Asymptotic Algorithm Analysis & Sorting Asymptotic Algorithm Analysis & Sorting (Version of 5th March 2010) (Based on original slides by John Hamer and Yves Deville) We can analyse an algorithm without needing to run it, and in so doing we can

More information

Complexity Theory Part I

Complexity Theory Part I Complexity Theory Part I Problem Problem Set Set 77 due due right right now now using using a late late period period The Limits of Computability EQ TM EQ TM co-re R RE L D ADD L D HALT A TM HALT A TM

More information

Algorithm efficiency analysis

Algorithm efficiency analysis Algorithm efficiency analysis Mădălina Răschip, Cristian Gaţu Faculty of Computer Science Alexandru Ioan Cuza University of Iaşi, Romania DS 2017/2018 Content Algorithm efficiency analysis Recursive function

More information