You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: 4-maps-hashing/Hashing-notes.md
+9
Original file line number
Diff line number
Diff line change
@@ -46,3 +46,12 @@ What number would you recommend his function to divide by to speed it up?
46
46
87 creates collisions.
47
47
125 is divisible by 5 and hence also creates collisions.
48
48
1001 is wasted space.
49
+
50
+
### Hash Maps and String Keys
51
+
52
+
Starting with a key value pair, one can run the keys through a hash function and then store the value in the bucket belonging to the hashed result of the key.
53
+
54
+
This can be done with strings too, most typically by using the ASCII value of the string. Python's ord() function converts a char into its ASCII value, and the chr() function converts it back.
55
+
56
+
Apparently the standard in Java prefers big hash tables over collisions, so they use an equation like:
0 commit comments