Lecture 8: Hashing with Chaining
Why Stack Overflow recommends it
Stack Overflow users link it as a clear reference on how hash tables and chaining work, both to back up answers about data structure choice and as context for questions about hash collisions.
Recommended by 2 people across 2 different months, 2015 to 2017.
What it is
A university lecture from MIT's 6.006 Introduction to Algorithms course, taught by Erik Demaine. It covers hash tables and collision resolution by chaining, including how hash functions work and why lookups are expected O(1).
What people said
Recommends Sebastian L · 2015-06 · Stack Overflow · on “What is the best way to organize a lot of data which contains multiple conditions?”
I would achieve this using a custom hashingalgorithm with simple linking and no probing if its the same value. That would be the fastes way. You could start like using the indexnumbers of enums or lengths of the string result or whatever. just return the List.Count() and youre good. if you need more information about hashing you should watch this: [this video] EDIT: after reading your comment, if you just want to generate all permutations you should make enums or list with the possible values for a category. Then adapt the code to c# from this question How to generate all permutations of a list in Python [LINK]
Recommends Zoomba · 2016-02 · Stack Overflow · on “Data structure for writing a dictionary in java”
According to the lecture in Introduction to Algorithms of MIT, I would say it is better to go with hash-tables. Because you can do operations in O(1) instead of O(logn) [this video]
Cites SeanPlusPlus · 2016-05 · Stack Overflow · on “Hash collision with 2 strings in Python”
In the MIT OpenCourseWare YouTube lecture on hashing [this video] , the professor gives an example of two strings causing a hash collision in Python: >>> hash('\0B') 64 >>> hash('\0\0C') 64 Why does this happen?
Cites lostsoul29 · 2017-02 · Stack Overflow · on “Why does a HashMap contain a LinkedList instead of an AVL tree?”
The instructor in this video [this video] explains that hash map implementations usually contain a linked list to chain values in case of collisions. My question is: Why not use something like an AVL tree (that takes O(log n) for insertions, deletions and lookups), instead of a linked list (that has a worst case lookup of O(n))? I understand that hash functions should be designed such that collisions would be rare. But why not implement AVL trees anyway to optimize those rare cases?