Hash
Operation
Insert:
O(1)
Delete:
O(1)
Find:
O(1)
Hash Function
Magic Number 33
Hash Collision
1. Open Hashing
Use Linked List to chain different elements on the same position. 这个 Visualization 挺好的。
https://www.cs.usfca.edu/~galles/visualization/OpenHash.html
2. Closed Hashing
Use Array to allocate different elements. If the position is occupied, move to the next available position. 这个 Visualization 挺好的。
https://www.cs.usfca.edu/~galles/visualization/ClosedHash.html
3. Rehashing
Thread Safe
In Java, which one is thread safe? HashMap, HashSet and HashTable.
HashTable.
Last updated