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?

5 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/SignificantFidgets Apr 10 '26 edited Apr 10 '26

Inputs are not random. Look at EVERY possible input of size n, and then find the input of that size that takes the longest. That's your value of T(n). Do that for every n, and you have a function T(n) that is the worst-case time complexity.

Edit: As in my other comment, I misread the question as asking about worst-case complexity. Sorry.