GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 18

Average time compared with worst-case time

Algorithms · Asymptotic Analysis & Recurrences · Full GATE CSE 2012 paper

GATE 2012, Q18 1 mark · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 18, GATE 2012: 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?
        (A) A(n) = Ω(W(n))                              (B) A(n) = Θ (W(n))
        (C) A(n) = O (W(n))                              (D) A(n) = o (W(n))
Tap to enlarge
Your answer
Answer & solution

Official answer: C

At a fixed input size, each running time is at most the maximum W(n). Taking an expectation over any input distribution preserves the inequality A(n)≤W(n). Hence A(n)=O(W(n)), C. Equality in order can occur, ruling out an always-strict little-o claim; no matching lower bound is guaranteed.

Check: Average time depends on a distribution; worst-case time does not. If every input takes n steps then A=W=n, disproving an unconditional o bound. If a rare expensive input exists, the average can be much smaller, disproving an unconditional Θ bound.

Original paper, page 4 · Answer key