Open In App

Algorithms | Analysis of Algorithms | Question 19

Like Article
Like
Save
Share
Report

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)

(A)

f3, f2, f4, f1

(B)

f3, f2, f1, f4

(C)

f2, f3, f1, f4

(D)

f2, f3, f4, f1


Answer: (A)

Explanation:

  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


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads