Analysis of Algorithms: Methods and Examples CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1
Using Limits 2
Using Limits: An Example 3
4
5
Big-Oh Transitivity 6
7
Big-Oh Hierarchy 8
Using Substitutions 9
10
Summations 11
Geometric Series A geometric series is a sequence C k of numbers, such that C k = D * C k-1, where D is a constant. How can we express C 1 in terms of C 0 ? – C 1 = D * C 0 How can we express C 2 in terms of C 0 ? – C 2 = D * C 1 = D 2 * C 0 How can we express C k in terms of C 0 ? – C k = D k * C 0 So, to define a geometric series, we just need two parameters: D and C 0. 12
Summation of Geometric Series 13
Summation of Geometric Series 14
Summation of Geometric Series 15
Approximation by Integrals 16
Solving Recurrences: Example 1 Suppose that we have an algorithm that at each step: – takes O(N 2 ) time to go over N items. – eliminates one item and then calls itself with the remaining data. How do we write this recurrence? 17
Solving Recurrences: Example 1 18
Solving Recurrences: Example 1 19
Solving Recurrences: Example 2 Suppose that we have an algorithm that at each step: – takes O(log(N)) time to go over N items. – eliminates one item and then calls itself with the remaining data. How do we write this recurrence? 20
Solving Recurrences: Example 2 21
Solving Recurrences: Example 2 22
Solving Recurrences: Example 3 Suppose that we have an algorithm that at each step: – takes O(1) time to go over N items. – calls itself 3 times on data of size N-1. – takes O(1) time to combine the results. How do we write this recurrence? 23
Solving Recurrences: Example 3 24 finite summation
Solving Recurrences: Example 3 25
Solving Recurrences: Example 4 Suppose that we have an algorithm that at each step: – calls itself N times on data of size N/2. – takes O(1) time to combine the results. How do we write this recurrence? 26
Solving Recurrences: Example 4 27
Solving Recurrences: Example 4 28
Solving Recurrences: Example 4 29
Solving Recurrences: Example 4 30
Solving Recurrences: Example 4 31
Solving Recurrences: Example 4 32
Big-Oh Notation: Example Problem 33
Big-Oh Notation: Example Problem 34