Question
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?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2012 answer key
Solution
Analyze the definitions of worst-case complexity and average-case complexity .
-
Let be the set of all valid inputs of size , and let denote the running time of the algorithm on input .
-
The worst-case running time is the maximum running time over all inputs of size :
- The average-case running time is the expected running time across all inputs distributed according to probability distribution :
- Since for every input , and , we have:
-
Since for all , by definition of asymptotic upper bound, is always true.
-
Examination of other options:
- In QuickSort, while . Here and , ruling out (A) and (B).
- In MergeSort, and , so , ruling out (D).
C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2012 Computer Science and Information Technology (CS)
- Question
- 18 of 65, printed as CS Q.18
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.