If an algorithm takes 3n² + 5n + 20 steps for an input of size n, what is its Big-O complexity?
Correct answer D. O(n²)
Explanation
Big-O keeps only the fastest-growing term and drops constant factors. For large n, 3n² dominates 5n and 20, and the constant 3 is discarded, giving O(n²). Writing O(3n²) is not wrong mathematically but is not the simplified form expected. O(n³) is a valid upper bound yet not a tight one, so it is not the best answer.
Answer checked How we write and check questions
Discussion