GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 12

Comparing quadratic and log-linear costs

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

GATE 2010, Q12 1 mark · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 12, GATE 2010: A database contains 10^k records. To process n records, package A takes 0.0001n² time units and B takes 10n log₁₀n time units. What is the smallest offered value of k for which B is preferred to A?
Options: (A) 12; (B) 10; (C) 6; (D) 5.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Put n=10k. Package B is faster when 10·10k·k < 0.0001·102k, equivalently 10k−5>k. At k=5 this is 1>5, false; at k=6 it is 10>6, true. For positive integer k≤5, 10k−5≤1≤k, so 6 is the smallest positive integer exponent, C. The meaningful growing-database interpretation excludes the degenerate n=1 case k=0.

The inequality compares actual running-time formulas, not only asymptotic orders. At k=5, A=106 and B=5×106 time units, so A wins. At k=6, A=108 and B=6×107, so B wins. This illustrates why the smaller-growth algorithm need not be faster at small inputs when its constant factor is much larger.

Original paper, page 3