Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamesroutley/write-a-hash-table
✏️ Learn how to write a hash table in C
https://github.com/jamesroutley/write-a-hash-table
c data-structures hash-tables tutorial
Last synced: 6 days ago
JSON representation
✏️ Learn how to write a hash table in C
- Host: GitHub
- URL: https://github.com/jamesroutley/write-a-hash-table
- Owner: jamesroutley
- License: mit
- Created: 2017-08-04T13:05:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-16T14:30:33.000Z (12 months ago)
- Last Synced: 2024-11-29T04:02:32.551Z (13 days ago)
- Topics: c, data-structures, hash-tables, tutorial
- Homepage:
- Size: 51.8 KB
- Stars: 3,496
- Watchers: 66
- Forks: 280
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome - write-a-hash-table - ✏️ Learn how to write a hash table in C (Others)
README
[](/README.md) [](/.translations/fr/README.md)
# Write a hash table in C
[Hash tables](https://en.wikipedia.org/wiki/Hash_table) are one of the most useful data structures. Their quick and scalable
insert, search and delete make them relevant to a large number of computer
science problems.In this tutorial, we implement an [open-addressed](https://en.wikipedia.org/wiki/Open_addressing), [double-hashed](https://en.wikipedia.org/wiki/Double_hashing) hash table in
C. By working through this tutorial, you will gain:- Understanding of how a fundamental data structure works under the hood
- Deeper knowledge of when to use hash tables, when not to use them, and how
they can fail
- Exposure to new C codeC is a great language to write a hash table in because:
- The language doesn't come with one included
- It is a low-level language, so you get deeper exposure to how things work at a
machine levelThis tutorial assumes some familiarity with programming and C syntax. The code
itself is relatively straightforward, and most issues should be solvable with a
web search. If you run into further problems, please open a GitHub
[Issue](https://github.com/jamesroutley/write-a-hash-table/issues).The full implementation is around 200 lines of code, and should take around an
hour or two to work through.## Contents
1. [Introduction](/01-introduction)
2. [Hash table structure](/02-hash-table)
3. [Hash functions](/03-hashing)
4. [Handling collisions](/04-collisions)
5. [Hash table methods](/05-methods)
6. [Resizing tables](/06-resizing)
6. [Appendix: alternative collision handling](/07-appendix)## Credits
This tutorial was written by [James Routley](https://twitter.com/james_routley),
who blogs at [routley.io](https://routley.io).