Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does O(logn) + O(n) mean?

I was just told by someone that my code should follow the complexity guideline of O(logn) + O(n). When prompted for clarification, I was presented with, "the complexity of the code :)" In any event, any clarification over and above the provided would be appreciated.

like image 376
Benjamin Powers Avatar asked Dec 28 '22 16:12

Benjamin Powers


2 Answers

O(logn) + O(n) = O(n)

"I was just told by someone that my code should follow the complexity guideline of O(logn) + O(n)" - without knowing what your code is supposed to do, no one can answer what its reasonable complexity should be.

See Big O notation

like image 197
Mitch Wheat Avatar answered Feb 19 '23 07:02

Mitch Wheat


Without context, this is rather difficult to answer. "O(logn) + O(n)" by itself makes little sense because the asymptotic complexity of any given algorithm would be dominated by the linear term, so writing "+ O(logn)" doesn't clarify anything.

like image 23
pg1989 Avatar answered Feb 19 '23 06:02

pg1989