Hash Table with Chaining

  1. Hash function: it returns a positive integer that is called hash code.
  2. An Array: it is capable of storing data of the type we want to store
  • Use only the data being hashed -> we don’t want to incorporate anything else other than the data
  • Use all the data being hashed -> we want to use all of the data
  • Be deterministic -> every time we pass the same data we should get the same hash code
  • Uniformly distribute data -> data should be spread out through out the able
  • Generate very different hash code for very similar data
Example of a hash table

What about Collision?

How Chaining works

Implementation of Hash Table with Chaining

Hash Table constructor
Hash Function
Insert function
Function to know number of items stored in that index

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store