Best, Average and Worst Case
The same algorithm costs differently on different inputs. Each case is a separate statement.
Best, Average, Worst: Worst case: reversed
Before running: the best case is n - 1 = 5 comparisons, one per element. The worst is n(n - 1) / 2 = 15, when every element walks past everything before it. Which will this input be?
Cost
- Space
- O(1)
Before this
Related
Leads to
Topics that need this one first.