The asymptotic complexity of 4 functions f1, f2, f3, f4 are
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = n log n
f4(n) = n^(log n)
Arrange them in increasing order of complexity.
- (A)
f2, f3, f4, f1
- (B)
f1, f2, f3, f4
- (C)
f3, f2, f4, f1
- (D)
f3, f1, f2, f4
The asymptotic complexity of 4 functions f1, f2, f3, f4 are
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = n log n
f4(n) = n^(log n)
Arrange them in increasing order of complexity.
f2, f3, f4, f1
f1, f2, f3, f4
f3, f2, f4, f1
f3, f1, f2, f4
ANSWER
The increasing order is , which is option (c).
Official answer: CSource: ISRO's revised and final answer key of 16 February 2024
Compare with . Divide both by : against . A logarithm grows slower than any positive power of , so . Hence .
Compare with . The exponent eventually exceeds and keeps growing, while is constant. So . Hence .
Compare with by taking logarithms (base 2): and . Since , we get .
Combining: , that is .
Check the options: (a) puts before , which is wrong. (b) puts the exponential first, which is wrong. (d) puts before and , which is wrong. Only (c) matches the order .
KEY IDEA
Compare growth rates by dividing out common factors or by taking logarithms: is smaller than any power , a function is super-polynomial but still below because .
WATCH OUT FOR
Treating as a polynomial and placing it below , or treating it as exponential and placing it above . Its exponent grows without bound, so it beats every fixed power of , yet its logarithm is far smaller than .
From the ISRO CS 2023 paper. Every question of this paper · The full paper (PDF, ISRO) · All 2 ISRO Complexity questions, with notes