Skip to content

Evhevh/HashMap-Implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HashMap

This project implements two types of hash maps in Python:

  • Separate Chaining Hash Map (hash_map_sc.py): Uses linked lists to handle collisions.
  • Open Addressing Hash Map (hash_map_oa.py): Uses quadratic probing and tombstones for collision resolution.

Features

Usage

Each hash map file contains a HashMap class with the following methods:

  • put(key, value): Insert or update a key-value pair
  • get(key): Retrieve the value for a key
  • remove(key): Remove a key-value pair
  • contains_key(key): Check if a key exists
  • resize_table(new_capacity): Resize the hash table
  • get_keys_and_values(): Get all key-value pairs as a dynamic array
  • clear(): Remove all entries
  • table_load(): Get the current load factor
  • empty_buckets(): Count empty buckets

See the bottom of hash_map_sc.py and hash_map_oa.py for example usage and test cases.

Requirements

  • Python 3.6+
  • No external dependencies

File Overview

  • a6_include.py: Shared data structures and hash functions
  • hash_map_sc.py: Separate chaining hash map implementation
  • hash_map_oa.py: Open addressing hash map implementation
  • README.md: Project documentation

Running Tests

You can run either hash map file directly to execute the included test cases:

python hash_map_sc.py
python hash_map_oa.py

License

This project is for educational purposes.

About

HashMap Implementation using both Separate Chaining and Open Addressing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages