Volkswagen
Volkswagen

Reputation: 165

Time Complexity best, worst and average case

Hi guys Can you explain to me this in simple words

  1. Best-case complexity -of the algorithm is the function defined by the maximum number of steps taken on any instance of size N
  2. Worst-case complexity -of the algorithm is the function defined by the maximum number of steps taken on any instance of size N
  3. Average-case complexity- of the algorithm is the function defined by the average number of steps on any instance of size N

Upvotes: 0

Views: 900

Answers (1)

mcopik
mcopik

Reputation: 341

The worst-case is the one on which your algorithm requires the biggest number of operations. So, if you use this solution on some input data, then the worst-case complexity will give the upper bound i.e. it won't be worse than this. On the other hand, the best-case tells that your algorithm won't be better on any input data.

The average case gives you the average complexity of operations, when running on many samples of input data.

Upvotes: 1

Related Questions