UGC-NET Jun 2014 · Asymptotic Analysis & Recurrences

MCQ · 2 marks · Problem PROG-DIVC-0007

Big-$O$ estimates for the factorial function and the logarithm of the factorial function i.e. $n!$ and $\log n!$ is given by
  1. A
    $O(n!)$ and $O(n \log n)$
  2. B
    $O(n^{n})$ and $O(n \log n)$
  3. C
    $O(n!)$ and $O(\log n!)$
  4. D
    $O(n^{n})$ and $O(\log n!)$

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionBound each factor of \(n!\) by \(n\):\[n!=1\cdot2\cdots n\le n\cdot n\cdots n=n^n\ \Rightarrow\ n!=O(n^n).\]Taking logarithms:\[\log n!\le\log n^n=n\log n\ \Rightarrow\ \log n!=O(n\log n).\]The estimates asked for are in terms of simple functions, which gives \(O(n^n)\) and \(O(n\log n)\). Writing \(O(n!)\) or \(O(\log n!)\) just restates the function and is not an estimate.Answer: B

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com