logoalt Hacker News

mwkaufmayesterday at 5:59 PM1 replyview on HN

Every O(n) is O(1) if n = 1. Complexity measures worst-case by-definition, not all cases.


Replies

IsTomyesterday at 6:06 PM

It has two parameters and depending on their relation it will act differently, it's reasonable to include this information. It is worst case O(1) when n and k don't differ much.

show 1 reply