Intuitive Analysis

Here's how to see that this is linear time.

All the work is in doing swaps, and in incrementing i if no swap is needed.

How many times can we increment i?

How many times can we do swaps?

So, all the work is O(n).

Potential function analysis is just a more formal way of making this argument.


next up previous
Next: Potential Function Basics Up: POTENTIAL FUNCTION ANALYSIS Previous: Empirical Observation