Recursive Function: Function that depends on itself
- Base case to complete recursion
- Runtime of recursive functions can be expressed as recursive functions
- Recursive functions can be converted to explicit functions
Asymptotics
- $\prec$ Little-O: $\forall k \in \R_{>0}, \exists n_0 \in \N, \forall n \in \N, (n > n_0 \Rightarrow f(n) < k g(n))$
- $\preceq$ Big-O: $\exists k \in \R_{>0}, \exists n_0 \in \N, \forall n \in \N, (n > n_0 \Rightarrow f(n) \le k g(n))$
- $\approx$ Big-$\Theta$: $\exists k_1, k_2 \in \R_{>0}, \exists n_0 \in \N, \forall n \in \N, (n > n_0 \Rightarrow k_1 g(n) \le f(n) \le k_2 g(n))$
- $\succeq$ Big-$\Omega$: $\exists k \in \R_{>0}, \exists n_0 \in \N, \forall n \in \N, (n > n_0 \Rightarrow f(n) \ge k g(n))$
- $\succ$ Little-$\omega$: $\forall k \in \R_{>0}, \exists n_0 \in \N, \forall n \in \N, (n > n_0 \Rightarrow f(n) > k g(n))$
Quick Rule:
- $1 \prec \log(n) \prec n^{0.001} \prec n \prec n \log(n) \prec n^{1.001} \prec n^{1000} \prec 1.001^n \prec 2^n$
- $\lim_{n\to\infin}\frac{f(n)}{g(n)}=0 \Leftrightarrow f \prec g$
Simplifications
- Base case when proving $T=O(f)$ or $T=\Omega(f)$ is always true.
- Ignore floors and ceilings
- Substitution Method:
- Make a guess for $f$ s.t. $T(n)=O(f(n))$
- Write out the recurrence: $T(n)=\dots$
- Substitute $T(k)$ on the right with $cf(k)$
- Prove $T(n)\le cf(n)$
- Pick $c$ to finish proof
Standard Form Recurrences
$T(n)=aT(n/b)+f(n)$