DEV Community

Cover image for 4 tricks to boost up your algorithms game

4 tricks to boost up your algorithms game

Carlos Roso on June 11, 2020

TL;DR. Associate O(1) with table lookups and math O(n) is for list traversal The weird logarithm is for sorting: O(nlogn) Connect O(n2) with nest...
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

Collapse
 
caroso1222 profile image
Carlos Roso

I'm always happy to share what I learn, glad you liked it!

Collapse
 
marln94 profile image
marln94

I'm starting to take this kind of interviews for remote work and find this guide so helpful, thanks!

Collapse
 
caroso1222 profile image
Carlos Roso

Nice, good luck with your interviews!

Collapse
 
tarise profile image
Nikki

Bless you.

Collapse
 
caroso1222 profile image
Carlos Roso

🙏

Collapse
 
thisdotmedia_staff profile image
This Dot Media

This is awesome Carlos! Love it 🙌

Collapse
 
caroso1222 profile image
Carlos Roso

Appreciate it, I'm glad you liked it!

Collapse
 
nuacem profile image
Nuacem AI

Nice work man, Creative Algo here i see , it will so helpful and i hope i can use it for conversational AI. Thank you

Collapse
 
caroso1222 profile image
Carlos Roso

Im glad you found it helpful!