AlgoScope

Best, Average and Worst Case

The same algorithm costs differently on different inputs. Each case is a separate statement.

Complexity analysis, analysis, beginner
Predict the number of comparisons before the sort runs. Best is 5, worst is 15.3002111721238435i
Predict the number of comparisons before the sort runs. Best is 5, worst is 15.3002111721238435i

Best, Average, Worst: Worst case: reversed

Decision, step 2 of 8

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?

How best, average, worst works

Cost

Space
O(1)

Before this

Leads to

Topics that need this one first.