• edited by
28,482 views
59 59 votes

Consider the following functions:

  • $f(n) = 2^n$
  • $g(n) = n!$
  • $h(n) = n^{\log n}$

Which of the following statements about the asymptotic behavior of $f(n)$, $g(n)$ and $h(n)$ is true?

  1. $f\left(n\right)=O\left(g\left(n\right)\right); g\left(n\right)=O\left(h\left(n\right)\right)$
  2. $f\left(n\right) = \Omega\left(g\left(n\right)\right); g(n) = O\left(h\left(n\right)\right)$
  3. $g\left(n\right) = O\left(f\left(n\right)\right); h\left(n\right)=O\left(f\left(n\right)\right)$
  4. $h\left(n\right)=O\left(f\left(n\right)\right); g\left(n\right) = \Omega\left(f\left(n\right)\right)$

9 Answers

Best answer
58 58 votes

$g(n) = n!$.

On expanding the factorial we get $g(n) = O(n^n)$ :$$\begin{align*} n^n &> n^{\log n} \\ n^n &> 2^n \end{align*}$$This condition is violated by options $A$, $B$ and $C$ by first statements of each. Hence, they cannot be said to be TRUE.

Second statement of option $D$ says that $g(n)$ is asymptotically biggest of all.

Answer is option (D).

• edited by
2 flags:
✌ Low quality (Anurag Prasad “Incorrect explanation. Given explanation can not be used to conclude that the first 3 options are incorrect.”)
✌ Low quality (Alok_Mandal)
37 37 votes
  $f(n)$ $g(n)$ $h(n)$
$n = 2^{10}$ $2^{1024}$ $1024!$ ${2^{10}}^{10} = 2^{100}$
$n = 2^{11}$ $2^{2048}$ $2048!$ $2^{121}$
Increase $2^{1024}$ $1025 \times 1026 \times \dots \times 2048$ $2^{21}$

So, growth rate is highest for $g(n)$ and lowest for $h(n)$. Option D. 

33 33 votes
Take log of all function with base 2

log(f(n)) = Log(2^n)  = n

log(g(n)) = Log(n!) = Log(n^n) // using sterling approximation = nlogn

Log(h(n)) = Log(n ^ logn) = log(n) * log(n).

It becomes clear now that h(n) < f(n) < g(n).

Looking at options D is only option which satisfy this constraints.
11 11 votes

Answer is D.

1 < loglogn < logn < ne < nc < nlogn < cn < nn < cc^n < n! .

2 2 votes

Take log on both sides of the functions and compare each functions.

eg   2n   n!

taking log on both sides

nlog(base 2)  log(n!)

and put n = 2^128 or some 2^k values

 ll get

nlog(base2) < log(n!)

and simlarly for 2^n and n^logn
 
now, 2^n > n^logn
 
so n! > 2^n > n^logn
 
Answer is (D).
 
correct me if i'm wrong
2n
Answer:
Position:
Show:

Related questions

74 74 votes
4 answers 4 answers
36.1k
36.1k views
Kathleen asked Sep 12, 2014
36,136 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...
30 30 votes
3 answers 3 answers
11.9k
11.9k views
go_editor asked Apr 23, 2016
11,904 views
Consider the following C program that attempts to locate an element $x$ in an array $Y[ \ ]$ using binary search. The program is erroneous. f (int Y[10] , int x) { int i,...
43 43 votes
6 answers 6 answers
22.1k
22.1k views
go_editor asked Apr 23, 2016
22,143 views
Consider the following C functions:int f1 (int n) { if(n == 0 || n == 1) return n; else return (2 * f1(n-1) + 3 * f1(n-2)); } int f2(int n) { int i; int X[N], Y[N], Z[N];...
38 38 votes
6 answers 6 answers
11.1k
11.1k views
go_editor asked Apr 23, 2016
11,079 views
Let $x_n$ denote the number of binary strings of length $n$ that contain no consecutive $0$s.The value of $x_5$ is $5$$7$$8$$16$