Member-only story

Why is Worst Case Analysis Mostly Used?

Raheelanjum
3 min read3 days ago

--

Average Case : The average case analysis is not easy to do in most practical cases and it is rarely done. In the average case analysis, we need to consider every input, its frequency and time taken by it which may not be possible in many scenarios

Best Case : The Best Case analysis is considered bogus. Guaranteeing a lower bound on an algorithm doesn’t provide any information as in the worst case, an algorithm may take years to run.

Worst Case: This is easier than average case and gives an upper bound which is useful information to analyze software products.

Interesting information about asymptotic notations:

A) For some algorithms, all the cases (worst, best, average) are asymptotically the same. i.e., there are no worst and best cases.

ExampleMerge Sort does order of n log(n) operations in all cases.

B) Where as most of the other sorting algorithms have worst and best cases.

Example 1: In the typical implementation of Quick Sort (where pivot is chosen as a corner element), the worst occurs when the input array is already sorted and the best occurs when the pivot elements always divide the array into two halves.

--

--

Raheelanjum
Raheelanjum

Written by Raheelanjum

Highly skilled and experienced content writer dedicated to crafting compelling, informative content that resonates with diverse audiences. Expertise spans blog

Responses (26)