r/AskComputerScience • • Apr 10 '26

What is average case complexity?

the average-case complexity of an algorithm is the amount of some computational resource (typically time) used by the algorithm, averaged over all possible inputs.

Aren't there infinite possible inputs? How does that make sense?

4 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/SignificantFidgets Apr 10 '26

Oops. I don't know how I misread that, but despite it clearly saying "average case" above I read that as "worst case." Apologies.

For average case you do indeed average over inputs of each size, but you need to have a distribution on the inputs. Often people will take a uniform distribution of all inputs of size n, but that's not the only way to do it.

1

u/Leading-Fail-7263 Apr 10 '26

Thanks! No worries!