Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?
Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE? Correct Answer A(n) = O (W(n))
The correct answer is "option 3".
CONCEPT:
There are three types of complexities:
1. Worst case: It is the maximum running time taken by any algorithm.
2. Average case: It is the average running time taken by any algorithm.
3. Best case: It is the minimum running time taken by any algorithm.
EXPLANATION:
The average case time can be equal to or lesser than the worst case.
So, A(n) would be the upper bound case by W(n).
Also, it will not be a strict upper bound as it can be the same as an average case like Merge sort.
Therefore,
A(n) = O(W(n))
Hence the correct answer is "option 3".