DEV Community

Discussion on: "Big Oh": Is my reasoning right?

Collapse
 
curtisfenner profile image
Curtis Fenner • Edited

There's a much more succinct and formal way of putting what I think your reasoning is:

if the limit of f(n) / g(n) is a finite number as n goes to infinity, then f is O(g).

So for example, if you're comparing 3𝑛³ + 2n² to 5𝑛³, the limit of the ratio is 3/5, which is a finite number, so 3𝑛³ + 2n² is O(5𝑛³).

On the other hand, if we compare 10n² and n, the limit is +infinity. So that means 10n² is NOT O(n).

Collapse
 
tanguyandreani profile image
Tanguy Andreani

Thank you for this. It doesn’t exactly help regarding my reasoning but I think your method is easier to prove that f is O(g). I didn’t know about it so thanks for introducing it to me^