r/AskComputerScience • u/SaltyAir6808 • Apr 04 '26
I need help
“Using the formal definition of Big-O notation, prove that the function f(n) = 3n^2 + 5n + 2
is 0 (n^2).
I’m so sorry to be posting like this but I’m a beginner as you can see and I’m really having a hard time at this i watched like 10 video explaining it my brain is fried. can anyone help me with it?
0
Upvotes
View all comments
Show parent comment
2
u/teraflop Apr 04 '26
Your approach isn't wrong, but that's not a complete solution because you've just asserted this without proof:
The simplest way to prove this rigorously is to rewrite it as (7n2) - (3n2 + 5n + 2) ≧ 0. Then you show that the left hand side of this inequality is an increasing function. So if the inequality holds at n=2, then it also holds for all values n≧2.
One way to show this is with calculus. If you call the left-hand side g(n), you can prove that g(n) is increasing by showing that the derivative g'(n) is non-negative and then applying the mean value theorem.
Or without calculus, you can treat g as a function on integers, and then use algebra to show that g(n+1) ≧ g(n). So if g(n) is non-negative then g(n+1) is also non-negative, and by induction g(n)≧0 for all values n≧2.