Download presentation
Presentation is loading. Please wait.
Published byAllen Wells Modified over 9 years ago
1
Lecture 3 Algorithm Analysis
2
Motivation Which algorithm to use?
3
Step-Counting Assumptions
4
Step-counting: equal work Adding/Multiplication/Division Trigonometric functions
5
Step-counting: no optimization Unrolling Loops
6
Sample code (simple operations)
7
Sample code (while loop)
8
Sample code (for loop)
9
Sample code: conditionals
11
Which branch do we follow? Best Case Average Case Worst Case
12
Code Sample if (x < 0){ for (i = 0; i < n; i++){ print(n) } else print false
13
Sample Code for (i = 0; i < n; i++){ if (a[i] > x){ for (j = 0; j < n; j++){ b[j] = b[i] } }else{ b[j] = 0 }
14
Limitations of step-counting Recursion Do Constants Matter?
15
Asymptotic Analysis Generalization/Categorization Abstraction
16
Big-O Definition
17
Graph
18
Using Big-O Show 7n+8 = O(n)
19
Using Big-O
20
Show 7n+8 = O(n^2)
21
Using Big-O
22
Upper Bounds
23
Common Labels FunctionNameExample
24
Theorems
27
Function Properties
28
Useful Tool: limits
29
Properties of Big-O and friends Symmetry Transpose Symmetry
30
Properties of Big-O and friends Reflexivity Transitivity
31
Common Misunderstandings Bounds vs. best/worst cases
32
Asymptotic Analysis vs. Running time
33
Lecture 3 Algorithm Analysis
34
Motivation Which algorithm to use?
35
Step-Counting Assumptions
36
Step-counting: equal work Adding/Multiplication/Division Trigonometric functions
37
Step-counting: no optimization Unrolling Loops
38
Sample code (simple operations)
39
Sample code (while loop)
40
Sample code (for loop)
41
Sample code: conditionals
43
Which branch do we follow? Best Case Average Case Worst Case
44
Code Sample if (x < 0){ for (i = 0; i < n; i++){ print(n) } else print false
45
Sample Code for (i = 0; i < n; i++){ if (a[i] > x){ for (j = 0; j < n; j++){ b[j] = b[i] } }else{ b[j] = 0 }
46
Limitations of step-counting Recursion Do Constants Matter?
47
Asymptotic Analysis Generalization/Categorization Abstraction
48
Big-O Definition
49
Graph
50
Using Big-O Show 7n+8 = O(n)
51
Using Big-O
52
Show 7n+8 = O(n^2)
53
Using Big-O
54
Upper Bounds
55
Common Labels FunctionNameExample
56
Theorems
59
Function Properties
60
Useful Tool: limits
61
Properties of Big-O and friends Symmetry Transpose Symmetry
62
Properties of Big-O and friends Reflexivity Transitivity
63
Common Misunderstandings Bounds vs. best/worst cases
64
Asymptotic Analysis vs. Running time
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.