edited by
17,098 views
40 votes
40 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)$
edited by

5 Answers

Best answer
49 votes
49 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
30 votes
30 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. 

23 votes
23 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.
9 votes
9 votes

Answer is D.

1 < loglogn < logn < n< n< nlogn < c< nn < cc^< n! .

Answer:

Related questions

7.3k
views
3 answers
24 votes
go_editor asked Apr 23, 2016
7,348 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, j, k; i ... ;Change line 7 to: } while $((Y[k] == x) \&\& (i < j))$ ;
13.1k
views
5 answers
33 votes
go_editor asked Apr 23, 2016
13,103 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 ... $ return the values$1661$ and $1640$59$ and $59$1640$ and $1640$1640$ and $1661$
5.5k
views
6 answers
24 votes
go_editor asked Apr 23, 2016
5,540 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$
10.5k
views
2 answers
33 votes
go_editor asked Apr 23, 2016
10,474 views
The subset-sum problem is defined as follows. Given a set of $n$ positive integers, $S = \{ a_1, a_2, a_3, \dots , a_n \}$, and positive integer $W$, is there a subset of $S$ whose ... $?$X[1, W]$X[n, 0]$X[n, W]$X[n-1, n]$