Reputation: 27193
Properties of a good hash function from MIT recitation:
Can some one explain the point 2 further . What does variable name has to do with hash functions ?
Edit: I work with Java . So if an answer contains explanation using java semantics it is okay to me .
Upvotes: 2
Views: 597
Reputation: 726639
Since hash tables are often used for building lookup tables that compilers use to look up information about symbols, such as variable names and function names, a compiler scenario is used to explain the point of #2.
The authors took a pair of variable names that are very commonly found in the same program, i
and j
, and said that strings representing the names of these variables, "i"
and "j"
, should not be hashed to the same slot. This makes sense, because resolving hash collisions is the part of the lookup process that most negatively influences the speed.
Upvotes: 3
Reputation: 359846
The bullet point suggests that compilers use something called a symbol table which is a mapping from variable name to information about that variable, implemented as a hash table.
Which is true of many compilers.
Upvotes: 2