0% found this document useful (0 votes)
3 views2 pages

Objective: 1. File Input

The document outlines a project to implement and compare four hashing techniques: Linear Probing, Quadratic Probing, Double Hashing, and Separate Chaining. It details the requirements for reading words from a file, preprocessing them, and applying specific hash functions and collision resolution strategies. The project aims to display hash values, insertion positions, and collision counts for each technique used.

Uploaded by

Hazem Hesham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Objective: 1. File Input

The document outlines a project to implement and compare four hashing techniques: Linear Probing, Quadratic Probing, Double Hashing, and Separate Chaining. It details the requirements for reading words from a file, preprocessing them, and applying specific hash functions and collision resolution strategies. The project aims to display hash values, insertion positions, and collision counts for each technique used.

Uploaded by

Hazem Hesham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures

Hashing Techniques

Objective
To implement and compare four different hashing techniques by
reading words from a file and storing them using hash functions and
collision resolution strategies.

Project Requirements

1. File Input
- Read a list of words from a text file (words.txt), formatted as:
- One word per line or
- Space-separated words
- Preprocess the input by converting words to lowercase

2. Hashing Techniques
Use this hash function

where: b = 31, n is word length and m = 109 + 9 ( largest prime number)

Implement the following four hashing techniques:

2.1. Linear Probing


- Collision resolution by sequentially checking the next slot (open
addressing):
Indexᵢ = (h₁(s) + i) mod T

2.2. Quadratic Probing


- Collision resolution using a quadratic function:
Indexᵢ = (h₁(s) + c₁·i + c₂·i²) mod T
- Typically: c₁ = c₂ = 1
2.3. Double Hashing
- Uses two hash functions:
- Primary: h₁(s) = H(s) mod T
- Secondary: h₂(s) = 97 - (H(s) mod 97)
Indexᵢ = (h₁(s) + i·h₂(s)) mod T

2.4. Separate Chaining (Open Hashing)


- Collision resolution using linked lists or dynamic arrays at each index.
- All elements with the same hash index are stored in a chain.

Functionality
- Read and store words into four different hash tables, one per
technique
- Show:
- Hash values
- Inserted positions
- Collision counts for each value

Output
Print or log the contents of each hash table:
- Show all words inserted
- Indicate where collisions occurred
- For separate chaining, show linked lists at indices

You might also like