Machine-translated by Google. Questions are authored in English.
Top

Discussion

Big-O estimates for the factorial function and the logarithm of the factorial function i.e. \(n!\) and \(\log n!\) is given by

  • A.\(O(n!)\) and \(O(n \log n)\)
  • B.\(O(n^{n})\) and \(O(n \log n)\)
  • C.\(O(n!)\) and \(O(\log n!)\)
  • D.\(O(n^{n})\) and \(O(\log n!)\)

Answer: B

The estimates are \(O(n^{n})\) for \(n!\) and \(O(n \log n)\) for \(\log n!\). Since \(n! = 1 \cdot 2 \cdots n\) is at most \(n \cdot n \cdots n = n^{n}\), \(n!\) is \(O(n^{n})\), and taking logarithms gives \(\log n! \le n \log n\), so \(\log n!\) is \(O(n \log n)\). The options that give \(O(n!)\) for \(n!\) are trivially true but not the estimate of the key, and \(O(\log n!)\) merely repeats the function.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.