DEV Community

Discussion on: 4 tricks to boost up your algorithms game

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

Good overview.

But pedantic me would like to point out that math is technically related to the number of bits in the data size. We usually deal with fixed sizes, but things like Python have unlimited integer size, and classes like BigDecimal are common in languages.

Hashmaps/tables, yeah, your linked site shows well the complexity there. So, average time O(1), but really, it's complicated. :)

Collapse
 
caroso1222 profile image
Carlos Roso

Good insight, thanks! Yeah, a worst-case scenario for hashmaps would require O(n) for read if all the objects happen to collide under the same hash (thus making the linked list abnormally large). As you point out, O(1) is a good average for newcomers and for interview purposes :D