All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · December 2023

Consider the following functions: f(n) = 3n√n, g(n) = 2√n log₂ n, h(n) = n!. Which of the following is true?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: D. f(n) is O(g(n))

Explanation

g(n) = 2√n log n = n√n, so f(n) = 3·g(n) and f is O(g) (and g is O(f)). n! grows faster than n√n, so h is not O(f) or O(g).

More Data Structures and Algorithms questions