Welcome to our community

Be a part of something great, join today!

How can big O's have values of the form A+B?

find_the_fun

Active member
Feb 1, 2012
166
For example according to wikipedia and this question bucket sort has the expected time complexity O(n+k). How does it make sense to use big O notation with arithmetic in it? Is it because it is not known which of n or k will determine the upper bound but once it is known (i.e. the algorithm is implemented) then it would be known if it actually is O(n) or O(k)?
 

CaptainBlack

Well-known member
Jan 26, 2012
890
For example according to wikipedia and this question bucket sort has the expected time complexity O(n+k). How does it make sense to use big O notation with arithmetic in it? Is it because it is not known which of n or k will determine the upper bound but once it is known (i.e. the algorithm is implemented) then it would be known if it actually is O(n) or O(k)?
To say that \(f(n,k)\in O(n+k)\) means that there exists a \(C>0\) such that for \(n+k\) large enough:

\[|f(n,k)| < C |n+k|\]

That is they jointly define the bound on the growth of \(|f(x,k)|\)

CB
 

chisigma

Well-known member
Feb 13, 2012
1,704
For example according to wikipedia and this question bucket sort has the expected time complexity O(n+k). How does it make sense to use big O notation with arithmetic in it? Is it because it is not known which of n or k will determine the upper bound but once it is known (i.e. the algorithm is implemented) then it would be known if it actually is O(n) or O(k)?
One of the basic property of the 'big-O notation' is that, if f and g are positive functions, then ...


$\displaystyle f_{1} \in \mathcal{O} (g_{1})\ \text{&}\ f_{2} \in \mathcal{O} (g_{2}) \implies f_{1}+f_{2} \in \mathcal{O} (g_{1}+g_{2}) $

Kind regards

$\chi$ $\sigma$