Hashed data structures
Introduction Common way of indexing data is by using hash maps which we use to map keys to values. The indexing of keys to values is built by using a hash function to compute which bucket or location our data will be stored in. If two pieces of data are hashed to the same location, it is called "collision". The Hash Function A hash function is basically a function that takes arbitrary data and returns a fixed length output. We usually call the output of a hash function as hash code. It is one of the most widely used data structures in modern programming. Properties of a hash function : 1. Deterministic :- A given input always generates the same output 2. Uniform :- The output should be probable in a given range public long DJBHash(String str) { long hash = 5381; for(int i = 0; i < str.length(); i++) { hash = ((hash << 5) + hash) + str.charAt(i); } return hash; } Perfect Hashing