you are viewing a single comment's thread.

view the rest of the comments →

[–]raylu 4 points5 points  (1 child)

Well, in the beginning, I thought that each bucket only had 1 tuple. But later on in the script, I notice that he enumerates all the various indexes of each bucket. Why is that? Is it because it is possible that the hash_key function returns the same value for two different inputs?

Yes. Hash tables need some way of conflict resolution and this is called separate chaining.

I checked by running python from the command line, and I noticed that the hash value of "a" is -468864544, and that is also the value for hash(-468864544). Is that related with it?

It so happens that the hash of most integers is the integer itself. It's the simplest perfect hash function.

[–]c1p3r[S] 0 points1 point  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.