Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Big-O notation - algorithm analysis

Is O(5n) = 5*O(n) ? From what I understand , O(5n) == O(n). Thus they are not equal? Please correct me if I am wrong.

like image 934
h4ck3d Avatar asked Jun 07 '26 21:06

h4ck3d


1 Answers

You only care the asymptotic behavior of the function and if f(x)/g(x) converges to a constant the two functions are defined to belong to the same big-O class. So as 5*n / n is always 5. So O(n) = O(5*n).

As for your question: O(f(x)) is defined as the set of functions having the same asymptotic behavior as f(x) and thus 5*O(N) is not defined. There is no such thing.

like image 184
Ivaylo Strandjev Avatar answered Jun 10 '26 19:06

Ivaylo Strandjev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!