> You flubbed the algorithm question. We're looking for someone with a stronger CS background.
When Triplebyte wanted me to go through their experimental interview, part of what I was asked was to "talk about" hash tables and, later, red-black trees. That seemed vague, but, prompted for what they were looking for, I covered the following:
- Hash tables are the generalization of arrays to non-integer indices. They have the access characteristics of arrays. They store data in a backing array.
- When two keys collide, the hash table can store them in a linked list (the "buckets" approach).
- If you don't like that, you can do quadratic probing, in which you repeatedly square an offset from the true hash value for that key, until you find a space in the backing array that is not currently full.
- Quadratic probing has the disadvantage that when you delete an entry from the table, you have to leave a placeholder in the backing array saying "there used to be something here!"
- If you generate an index into the backing array which is greater than its size, you would usually deal with that by taking the index modulus the size of the backing array.
- If the backing array gets too full, you would allocate a new backing array of double the size and rehash everything into the new backing array. You double the size so that amortized insert time stays constant.
- Amortized time complexity refers to the average amount of time taken for a set of completed operations.
- Red-black trees are a type of self-balancing binary tree with the property that all paths root to leaf are within a factor of two in terms of length. I can't say much more about them and wouldn't be able to write one off the top of my head.
The feedback they gave me was that, if I wanted to continue working with them, my highest priority should be to improve my knowledge of hash tables and red-black trees.
And sure, there's plenty of room for improvement in terms of red-black trees. But I am mystified as to what else they wanted for hash tables.