Posts

Showing posts from June, 2024

Hashing

Image
₪ Can't use hashing   if  order is important like "f ind key just smaller than given key" ₪ Requirements for hash function => H(key) = value     →  No matter how many times you pass key => value should always be same      →  If M is size of hash table => value from hash function must lie between 0 to M-1     → Value should be uniformly distributed for less collision COMPRESSION  MAP  => H(key) = key % M (M is prime number close to table size)  POLYNOMIAL  ACCUMULATION  =>  H(string) = [(s[0]*x^0) +  (s[1]*x^1) +  ....] % M   UNIVERSAL  HASHING -  choose any hash function uniformly at random *********************************************************************************** Direct Addressing --> exactly counting sort Create array of size r (size of universe of keys) -> in O(1) directly insert, delete or search => bcz it's array -> access that point...