We have best case, average case and worst case time complexities. So someone asks us about the complexity of an algorithm what is he referring to?
We have best case, average case and worst case time complexities. So someone asks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Colloquially: Usually, average case. This is why people say that Quicksort is O(N log N) time and a hash table lookup is O(K) time (K = key size). They are worst case O(N^2) and O(K*N), respectively. I recommend being explicit.
Academically: Usually, worst case. However, in academia people are usually interested in proving the complexity class for a given problem, rather than examining the complexity of an algorithm. For academicians, an algorithm might just be a handy proof for an upper bound on complexity rather than the actual object of study.
The other gotcha is that “average case” is entirely dependent on the input distribution. Most people assume uniform distributions, unless they use the phrase “real world” at which point it’s anybody’s guess what their input is.