VOOZH about

URL: https://www.geeksforgeeks.org/java/java-program-to-implement-hashtables-with-linear-probing/

⇱ Java Program to Implement HashTables with Linear Probing - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Program to Implement HashTables with Linear Probing

Last Updated : 23 Jul, 2025

Hashing is a technique that is used to uniquely identify a specific object from a group of similar objects. Suppose an object is to be assigned a key to it to make searching easy. To store the key/value pair, one can use a simple array like a data structure where keys (integers) can be used directly as an index to store values. However, in cases where the keys are large and cannot be used directly as an index, one should use hashing. In hashing, large keys are converted into small keys by using hash functions. The values are then stored in a data structure called hash table. Linear Probing, It may happen that the hashing technique is used to create an already used index of the array. In such a case, we can search for the next empty location in the array by looking into the next cell until we find an empty cell. This technique is called linear probing. 

There are three basic operations linked with linear probing which are as follows:

  • Search
  • Insert
  • Delete

Implementation: Hash tables with linear probing by making a helper class and testing this in the main class.

Example

 
 

Output: 


 

Random action performed over Hash Table 

  • Size is entered as : 5
  • Two key-value pairs are inserted
    • G 121
    • F 212
  • Later Hash table is cleared
👁 Image


 

Comment