0
Is O(n*log(n)) complexity better or O(n+klog(n)) complexity better? Can you explain how to determine it?k
Hi, I am trying to understand how the complexities work. I need a but help to understand how do we know which one would be better? Here k is smaller than n. Thanks
4 odpowiedzi
+ 2
if k is constant then you can ignore it .
second one will be O(log(n))
You can also use graphical approach .
plot graph of log(n) and k*log(n) , if you zoom out of it , both will seem to be overlapping ..
while n*log(n) and log(n) wont be overlapping ...
also n*log(n)=log(n^n) which is even worse than y=x
+ 1
Thanks Yaroslav Vernigora
0
Does that mean that If k is a constant, complexity shall become O(n+log(n))? Also if k becomes variable, the complexity shall be same as that of O(n2). Please clarify once Prashanth Kumar . Thanks