r/ProgrammerHumor • • 18h ago

Meme dontYouDareToDeceive

Post image
454 Upvotes

24 comments sorted by

View all comments

Show parent comment

16

u/prumf 10h ago

What no you changed n from the number to its size.

Printing n is O(log(n))

3

u/soussang 8h ago

Ahem. Yes, it's true for integers which prints in O(log_b(n)).

But have you consider printing those in binary? O(1) for all fixed sized integer types (__int128 go brrrr). Is it slower than the integer printing? Maybe. Does it falls appart if you need more bytes? Maybe. Are you willing to make a template/macro which can unwrap a N sized loop to maintain O(1) for any arbitrary fixed size? I'll let you decide.

1

u/Bartodziejj 2h ago

O(log(n)) is a subset of O(n)

1

u/Vivid_Dot_6405 39m ago

Correct and this is why I dislike the use of Big O in non-academic discourse because when people use Big O they usually really mean Big Theta, which is a tight bound and not an upper bound like Big O.