Review:

Untitled

Average-case Running Time

  1. Define sample space $S_n$: All inputs of size $n$ Each input $x\in S_n$, $t(x)$ is a random variable
  2. Given a probability distribution over $S_n$, $t_n=E[t(x)]=\sum_{x\in S_n} t(x)\cdot P(x)$ is the average-case runtime for size $n$ ”Let n be arbitary”
  3. $t(x)$ need to be exact (without constant factors)

Examples

QuickSort:

Randomized QuickSort: Since we don’t know the samples’ distribution, choose pivots at random to ensure the O(n log n) time

Amortized Analysis

Worst-case Sequence Complexity: Max total runtime to perform m operations from fixed starting point (typically start empty).

Amortized Analysis: Total sequence complexity when the worst time of individual elements are far larger than the average