educative.io

Replacing all variables with n^3?

Apologies if it seems like a dumb question, not a math guru.

At the first example when we say that we have changed every variable with n^3 shouldn’t that imply that following equation 3n^6+4n^4+2n^3 ? i don’t quiet get that, also on what basis we decided to replace?

Thanks in advance :slight_smile:


Course: Big-O Notation - Learn Interactively
Lesson: Educative: Interactive Courses for Software Developers

Hi @Mohamed_Halawa
Thanks for reaching out to us. Here, we attempt to validate the time complexity of the algorithm. In the equation, 3n^3+4n+2≤cn^3 we have replaced the variable part in all terms with n^3 which is the variable part of the highest order term. It becomes 3n^3+4n+2≤cn^3 => 3n^3+4n^3 +2n^3 ≤cn^3. We can see that the inequality would still hold true. We are not multiplying each term with n^3 in this case. If we multiply each term with n^3 then we would get 3n^6+4n^4+2n^3.
I hope it helps. Happy Learning :slight_smile: