AlgoGenesis / C

AlgoGenesis is a centralized open-source platform dedicated to providing optimized and well-documented algorithm implementations in C. Perfect for both beginners and advanced users, this repository serves as a comprehensive learning resource for solving algorithmic challenges.
MIT License
88 stars 276 forks source link

[NEW ALGORITHM] Implement Robin Hood Hashing in Hashmap for Optimized Probe Length Management #1462

Open divyalakshmi0 opened 1 day ago

divyalakshmi0 commented 1 day ago

Title: Implement Robin Hood Hashing in Hashmap for Optimized Probe Length Management

Description: Robin Hood Hashing is a unique technique within open addressing that improves the performance of hash tables by balancing the load factor and reducing clustering. This hashing method rearranges elements based on their probe distance: if a new element encounters an existing one with a shorter probe length, they swap positions. This approach ensures that "poorer" elements (those with longer probe distances) get closer to their ideal positions.

Key Points:

Implementation Tasks:

  1. Hash Table Setup: Initialize a hash table with open addressing, using a consistent hash function.
  2. Insertion with Robin Hood Logic:
    • Calculate the probe distance for each element.
    • On collision, compare probe distances; if the new element has a longer distance, swap it with the existing one.
    • Continue probing for the next available slot as per this logic.
  3. Search Function: Implement search logic that considers potential displacements.
  4. Delete Function: Ensure elements can be removed and reinserted as needed without breaking the probe-distance ordering.

Benefits:

This addition will significantly enhance the hash table’s performance, especially in scenarios where maintaining consistent access speed under high load is essential.

Labels:

new algorithm, gssoc-ext, hacktoberfest, level1


Assignees:

Riddhi12349 commented 19 hours ago

Please assign me