Welcome to our community

Be a part of something great, join today!

big-o notation

find_the_fun

Active member
Feb 1, 2012
166
For megre sort alogirthm the runtime is T(n)=nb+cnlog(n). It's not quite clear to me why this is O(nlogn) is it because b and c are constants?
 

CaptainBlack

Well-known member
Jan 26, 2012
890
For megre sort alogirthm the runtime is T(n)=nb+cnlog(n). It's not quite clear to me why this is O(nlogn) is it because b and c are constants?
It is because for \(n>n_0\) where \(n_0>0\) is greater than the base of the logarithm (so \( \log(n)>1\) )
:

\[|T(n)|=|n \; b+c\; n \log(n)|<|b| \; n+|c|\; n \log(n)<|b|\; n \log(n)+ |c|\; n \log(n) = A\; n \log(n)\]

CB
 
Last edited: