GC 211:data Structures: Week 2: Algorithm Analysis Tools
GC 211:data Structures: Week 2: Algorithm Analysis Tools
o If the program runs on a large data set, then the running time becomes an issue
What is Algorithm Analysis?
A methodology to predict the resources that the algorithm requires
Computer memory
Computational time
n3 – 3n = O(n3)
1 + 4n = O(n)
7n2 + 10n + 3 = O(n2)
2n + 10n + 3 = O(2n)
Big O: More Examples
f(n) = 7n – 2; 7n - 2 is O(n)
? Find c > 0 and n0 ≥ 1 such that 7n-2 ≤ c•n for n ≥ n0
This is true for c = 7 and n0 = 1
at n = 1, 7-2 ≤ 7; at n = 2, 14 – 2 ≤ 14, and so on