Search code examples
algorithmhashtableaddressing

What is the name for this hash table optimization?


While implementing a custom hash table with open addressing, I discovered that for my application, it helps performance if I swap the probed element in a row of filled slots with the one in the first probe location. (To optimize the table to quicker yield often-accessed elements)

Is there a name for this optimization?


Solution

  • Your problem is very similar to the list update problem from the field of online-competitive algorithms.

    The solution you used is known as MTF (move to front). This solution is known to be 2-competitive, meaning that it will do at most twice as bad as a hypothetical adversary which knows the future in advance.

    Note that you can do slightly better than that with the bit algorithm, which requires another bit + random op, but is 7-4 competitive.