4 ms·
> Not knowing when to use a hash table instead of a nested-for loop On the flip side, the O(1) look-up nature of hash tables make them the no-brainer data stru
by Apocryphon 8y ago
> Not knowing when to use a hash table instead of a nested-for loop
On the flip side, the O(1) look-up nature of hash tables make them the no-brainer data structure to use, at least for passing programming interviews. Perhaps more interesting test questions would be when not to use hash tables.
- entee 8y agoFully agreed. Most questions I got when I started out as a data scientist interviewing for jobs were pretty simple: "use a hash table to count stuff, join stuff, lookup stuff". However not once did I get asked, "why do databases not exclusively use hash tables if they're so good?" That's a much more interesting question, though perhaps out of scope for a data scientist. I'd add that I've never heard that question being asked of engineers, I'd love to hear of people out there getting it though.
- tombert 8y agoI actually got that exact question once, or pretty close to it. I'm paraphrasing, but the question was "Hash tables are cool, but what's a data structure they might use in a DB besides that?". This was pretty early in my career, so it stumped me, and he pointed out that a binary tree is used semi-often because of ordering.
- pedrosorio 8y agoI am surprised B-trees were not the first data structure in that discussion, as they are "famous" for being used in DBs. Although these days one should talk about "learned index structures" instead, I guess :)