19 ms·
I think I'd have trouble with the hashing function but unless you're using a basic modulo.
by whimsicalism 5y ago
I think I'd have trouble with the hashing function but unless you're using a basic modulo.
- cle 5y agoIMO this is the least interesting part of a question like "can you write a hash table", unless you're in an area where writing hash functions is a critical skill. You have to deal with collisions either way...the ideal solution for me testing someone's software engineering skills would be one that uses a crappy hash function, but can trivially swap it out for something better. (Maybe this is different than what a school is testing for though?)
- vidarh 5y agoI agree. If I gave a test like that and someone gave me an answer where the hash function was pretty much just a dummy I'd be fine with that as long as they were clearly aware it was just a dummy and hopefully could explain roughly the characteristics of a good hash function.
- DudeInBasement 5y agosearch_index = value & ((hash_length_power_of2) - 1)