Asymptotic Analysis
Worst case Analysis
- Gives us a gurantee about the upper bound
- In some cases, worst case occurs fairly often
Average case Analysis
- Often as bad as worst case
Best case Analysis
- Always happens on certain input
- Good only for showing bad lower bound
Asymptotic Notation
O-notation
- Provides an asymptotic upper bound of a function
- For a given function g(n), we denote O(g(n)) (pronounced “big-oh” of g of n) by the set of functions:
O(g(n))={f(n) ∣ ∃c, n0>0, 0≤f(n)≤cg(n), ∀n≥n0}
Ω-notation
- Provides an asymptotic lower bound of a function
Ω(g(n))={f(n) ∣ ∃c, n0>0, 0≤cg(n)≤f(n), ∀n≥n0}
Θ-notation
- Provides an asymptotic tight bound of a function
Θ(g(n))={f(n) ∣ ∃c1, c2, n0>0, 0≤c1g(n)≤f(n)≤c2g(n), ∀n≥n0}
Tip: O and o
f(n)≤cg(n)→f(n)<cg(n)
Calculating
Typically, we do like this when calculating asymptotic running time:
- Drop low-order terms
- Ignore leading constants
e.g. T(n)=An2+Bn+C=O(n2)
Question: Master Theorem