{"id":18369165,"url":"https://github.com/angusgmorrison/data-structures","last_synced_at":"2025-04-10T19:39:51.518Z","repository":{"id":99829371,"uuid":"227798249","full_name":"AngusGMorrison/data-structures","owner":"AngusGMorrison","description":"Multilingual implementations of essential data structures.","archived":false,"fork":false,"pushed_at":"2021-05-28T09:47:17.000Z","size":208,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T20:54:20.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AngusGMorrison.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-13T09:01:19.000Z","updated_at":"2021-05-28T09:47:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"e010596c-2a98-4307-bd74-f61ba1514146","html_url":"https://github.com/AngusGMorrison/data-structures","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngusGMorrison%2Fdata-structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngusGMorrison%2Fdata-structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngusGMorrison%2Fdata-structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngusGMorrison%2Fdata-structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngusGMorrison","download_url":"https://codeload.github.com/AngusGMorrison/data-structures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281424,"owners_count":21077423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T23:28:37.984Z","updated_at":"2025-04-10T19:39:51.484Z","avatar_url":"https://github.com/AngusGMorrison.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hash Tables\n\n## Separate Chaining\nEntries are stored in linked lists. Whenever a collision occurrs, the new entry is added to the list. On retrieval, if more than one entry exists at a location, the list is searched sequentially until the matching key is found.\n\nIn the best case, when entries are evenly distributed, separate chaining provides O(1) access. In the worst case, access takes O(n).\n\nRequires additional memory to maintain linked list nodes as opposed to storing data directly in the table. Data locality is also poor, as nodes may be stored in very different locations in memory.\n\n## Open Addressing\nEntries are stored in the table itself. Whenever a collision occurs, the insertion algorithm continues searching for a free spot by probing the table at intervals.\n\n### Linear Probing\nThe table is probed at fixed intervals (typically +1) until a free slot is found.\n\nRequires less memory than separate chaining, but suffers from clustering, where consecutive elements form groups and additional time is required to find the next free slot.\n\nHas the best cache locality of all addressing techniques.\n\n### Quadratic Probing\nReduces clustering by probing at quadratic intervals: hash(x), hash(x) + 1 * 1, hash(x) + 2 * 2, ...\n\nLies between linear probing and double hashing in terms of cache locality and clustering.\n\n### Double Hashing\nUses a second hashing alogrithm and searches for slot i * hash2(x) in the ith rotation if a free slot is not found:\n- hash(x) + 1 * hash2(x) % s\n- hash(x) + 2 * hash2(x) % s\n- hash(x) + 3 * hash3(x) % s\n- ...\n\nHas poor cache performance but no clustering. Requires more computation time as two hash functions must be run.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangusgmorrison%2Fdata-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangusgmorrison%2Fdata-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangusgmorrison%2Fdata-structures/lists"}