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
77 stars 242 forks source link

[NEW ALGORITHM] Add Hashmap Data Structure #1181

Open Riya7045 opened 3 hours ago

Riya7045 commented 3 hours ago

Hashmap

About:

We need to implement a hashmap (hash table) data structure to support efficient key-value storage and retrieval. The hashmap will offer basic functionalities like insertion, search, and deletion, with collision handling via chaining using linked lists. This implementation should work for integer keys and values as the primary use case.

Key Tasks:

Hashmap Structure:

Define a hashmap structure that includes an array of pointers (buckets). Each bucket should point to a linked list to handle collisions (chaining).

Hash Function:

Create a hash function that maps integer keys to an index based on the table size using modulo (% operator).

Basic Operations:

Insert: Add a key-value pair to the hashmap. Handle collisions by inserting the new entry into a linked list. Search: Retrieve a value based on a given key. If the key is not found, return a default error code (e.g., -1). Delete: Remove a key-value pair from the hashmap, handling re-linking of nodes in the linked list for collision cases.

Labels:

new algorithm, gssoc-ext, hacktoberfest, level1


Assignees:

lakshita10341 commented 3 hours ago

can u assign me this issue?