Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Robin Hood Hashing (Papers We Love SF August 2017)

Robin Hood Hashing (Papers We Love SF August 2017)

Robin Hood Hashing (1986) provided a breakthrough algorithm for storing data in hash tables, and has a really cool name. These slides were presented at the Papers We Love, Too meetup in San Francisco.

André Arko

August 24, 2017
Tweet

More Decks by André Arko

Other Decks in Programming

Transcript

  1. Robin Hood Hashing (1986) example hash table data LEIA HAN

    REY LUKE : ALDERAAN : CORELLIA : JAKKU : TATTOOINE
  2. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE HASHING ALGORITHM 2 4 0 4
  3. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 Robin Hood Hashing (1986)
  4. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 Robin Hood Hashing (1986)
  5. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 Robin Hood Hashing (1986)
  6. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN Robin Hood Hashing (1986)
  7. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN Robin Hood Hashing (1986)
  8. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA Robin Hood Hashing (1986)
  9. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA Robin Hood Hashing (1986)
  10. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  11. hash collisions LEIA HAN REY LUKE 2 4 0 4

    0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  12. resolving collisions: chaining LEIA HAN REY LUKE 2 4 0

    4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  13. 0 1 2 3 4 5 resolving collisions: open addressing

    LEIA HAN REY LUKE 2 4 0 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  14. 0 1 2 3 4 5 resolving collisions: open addressing

    LEIA HAN REY LUKE 2 4 0 4 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE Robin Hood Hashing (1986)
  15. 0 1 2 3 4 5 resolving collisions: open addressing

    LEIA HAN REY LUKE FINN 2 4 0 4 5 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE Robin Hood Hashing (1986)
  16. 0 1 2 3 4 5 6 Robin Hood Hashing

    (1986) resolving collisions: open addressing LEIA HAN REY LUKE FINN 2 4 0 4 5 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT
  17. 0 1 2 3 4 5 6 7 8 9

    Robin Hood Hashing (1986) resolving collisions: open addressing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL 2 4 0 4 5 9 6 8 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK LANDO:BESPIN MAUL:DATHOMIR
  18. 0 1 2 3 4 5 6 7 8 9

    Robin Hood Hashing (1986) worst-case performance: it’s really bad LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK LANDO:BESPIN MAUL:DATHOMIR LEIA:ALDERAAN
  19. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) worst-case performance: it’s really bad LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK+ LANDO:BESPIN+ MAUL:DATHOMIR+ WICKET:ENDOR LEIA:ALDERAAN
  20. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data 6 slots away from ideal LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK+ LANDO:BESPIN+ MAUL:DATHOMIR+ WICKET:ENDOR LEIA:ALDERAAN
  21. Robin Hood Hashing (1986) but a hero is on the

    horizon! Robin Hood Hashing offers vastly more efficient storage
  22. Robin Hood Hashing (1986) how much better is it, really?

    O(ln n) probes, where n is items in the hash
  23. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4
  24. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 REY:JAKKU 0
  25. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 REY:JAKKU 0 LEIA:ALDERAAN 0
  26. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LEIA:ALDERAAN 0
  27. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 LEIA:ALDERAAN 0
  28. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 LEIA:ALDERAAN 0
  29. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LEIA:ALDERAAN 0
  30. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 LEIA:ALDERAAN 0
  31. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  32. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  33. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  34. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 CHEWIE:KASHYYK 0 FINN:CORUSCANT 2 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  35. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 CHEWIE:KASHYYK 0 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0
  36. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 MAUL:DATHOMIR 1 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0
  37. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 MAUL:DATHOMIR 1 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0 CHEWIE:KASHYYK 1
  38. 0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) only 2 slots away from ideal LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 MAUL:DATHOMIR 1 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0 CHEWIE:KASHYYK 1
  39. Robin Hood Hashing (1986) stealing from the rich and giving

    to the poor? that’s Robin Hood all over
  40. Robin Hood Hashing (1986) further reading ‣ Robin Hood Hashing

    (1986 original paper) ‣ Robin Hood Hashing with Linear Probing paper (2005) ‣ Paul Khuong experimenting with hashing options (2009) ‣ Paul’s follow-up and conclusions (2011) ‣ Sebastian Sylvan saying robin hood should be the default (2013) ‣ Sebastian following up on slowness after deletions (2013) ‣ Emmanuel Goossaert benchmarking in C++ (2013) ‣ Paul Kuhong again, on linear probing for performance (2013) ‣ Emmanuel benchmarking again after tweaking deletions (2013)