Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Algorithms | Analysis of Algorithms | Question 19

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3, and f4?

  f1(n) = 2n
  f2(n) = n(3/2)
  f3(n) = n*log(n)
  f4(n) = nlog(n)


f3, f2, f4, f1


f3, f2, f1, f4


f2, f3, f1, f4


f2, f3, f4, f1

Answer: (A)


  f1(n) = 2^n
  f2(n) = n^(3/2)
  f3(n) = n*log(n)
  f4(n) = n^log(n)

Except for f3, all other are exponential. So f3 is definitely first in the output. Among remaining, n^(3/2) is next. One way to compare f1 and f4 is to take log of both functions. Order of growth of log(f1(n)) is Θ(n) and order of growth of log(f4(n)) is Θ(log(n) * log(n)). Since Θ(n) has higher growth than Θ(log(n) * log(n)), f1(n) grows faster than f4(n).

Following is another way to compare f1 and f4. Let us compare f4 and f1.

Let us take few values to compare

n = 32, f1 = 2^32, f4 = 32^5 = 2^25
n = 64, f1 = 2^64, f4 = 64^6 = 2^36

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads