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

7th Sep 2022, 7:58 AM
Ruchika Sehgal
Ruchika Sehgal - avatar
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
7th Sep 2022, 10:23 AM
Prashanth Kumar
Prashanth Kumar - avatar
7th Sep 2022, 11:45 AM
Ruchika Sehgal
Ruchika Sehgal - avatar
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
7th Sep 2022, 11:42 AM
Ruchika Sehgal
Ruchika Sehgal - avatar