Possible Duplicate:
Big O when adding together different routines
What does O(n) + O(log(n)) reduce to? My guess is O(n) but can not give a rigorous reasoning.
I understand O(n) + O(1) should reduce to O(n) since O(1) is just a constant.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well since
O( f(n) ) + O( g(n) ) = O ( f(n) + g(n) )We are simply trying to calculate anf(n)such thatf(n) > n + log(n)Since as n grows sufficiently
log(n) < nwe can say thatf(n) > 2n > n + log(n)Therefore
O(f(n)) = O(2n) = O(n)In a more general sense,
O( f(n) ) + O( g(n) ) = O( f(n) )ifc*f(n)>g(n)for some constant c. Why? Because in this casef(n)will “dominate” our algorithm and dictate its time complexity.