reading-notes

Hashtables

What is a Hashtable?

Why do we use them?

  1. Hold unique values
  2. Dictionary
  3. Library

What Are they

Hashing

Collisions

  1. A collision occurs when more than one key hashes to the same index in an array and a “perfect hash” will never have any collisions.

  2. Collisions are solved by changing the initial state of the buckets.

Hashmaps store and read the values

Hash maps do this to store values:

  1. accept a key
  2. calculate the hash of the key
  3. use modulus to convert the hash into an array index
  4. store the key with the value by appending both to the end of a linked list

Hash maps do this to read value:

  1. accept a key
  2. calculate the hash of the key
  3. use modulus to convert the hash into an array index
  4. use the array index to access the short LinkedList representing a bucket
  5. search through the bucket looking for a node with a key/value pair that matches the key you were given

What is the benifits of Hash ,Buckets,Collisions

  1. Hold unique values
  2. Dictionary
  3. Library

Internal Methods :

  1. Add()
  2. Find()
  3. Contains()
  4. GetHash()

Intro to Hash Tables

what is a hash table?

basics of hash tables ******