I'm trying to understand better the idea of O(n)
, so I'm wonder about this:
If we know that a>=b so O(a+b)=O(a)
?
I know that O(a)+O(a)=O(2a)=O(a)
, but I'm wondering if it's true for something that it's smaller then a, I mean - if O(a+b)=O(a)
.
I think that it's true because a+b=O(2a)
, but I'd like to know if I'm wrong...
(P.S. it will be true if a and b are constants?)
Thank you!
You're totally correct in simplifying O(a+b) = O(a) as per this case.
It's so because
Example :-
Let's assume
Then,you can see