Let and denote respectively, the worst case and average case running time of an algorithm executed on an input of size . Which of the following is ALWAYS TRUE?
View worked solution
Answer: C
By definition, the worst-case running time represents the maximum time taken by the algorithm over all possible inputs of size :
The average-case running time is the expected running time over all inputs of size , weighted by their probability of occurrence :
Since the running time for any individual input cannot exceed the worst-case running time (i.e., ), we can write:
Since , this simplifies to:
By the definition of Big-O notation, since for all , it is always true that:
Why other options are incorrect:
- Option A () & Option B (): These are not always true. For QuickSort, the average-case is and the worst-case is . Here, grows strictly slower than , so .
- Option D (): This is not always true. For MergeSort, both the average-case and worst-case running times are . Since they grow at the same rate, .
Free practice · Your answers on this page are not saved.
