• Stars
    star
    3,229
  • Rank 13,906 (Top 0.3 %)
  • Language
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✏️ Learn how to write a hash table in C

Write a hash table in C

Hash tables 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, double-hashed 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 code

C 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 level

This 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.

The full implementation is around 200 lines of code, and should take around an hour or two to work through.

Contents

  1. Introduction
  2. Hash table structure
  3. Hash functions
  4. Handling collisions
  5. Hash table methods
  6. Resizing tables
  7. Appendix: alternative collision handling

Credits

This tutorial was written by James Routley, who blogs at routley.io.

More Repositories

1

24a2

🏵 An ultra-minimalist game engine
TypeScript
711
star
2

news.routley.io

🗞 My personal RSS feed
Go
32
star
3

vim-logbook

🗄 A logbook in the comfort of your own vim
Vim Script
28
star
4

natto

A simple command-line web crawler.
Go
13
star
5

routley.io

Personal website
JavaScript
8
star
6

awscm

Manage AWS Credentials
Go
7
star
7

imagegrid

👩‍🎨 A CLI tool for stitching multiple images together
Go
7
star
8

algorithms-and-data-structures

C
7
star
9

slingshot

An interplanetary physics game
JavaScript
6
star
10

tangle

🧶 A literate programming tool for tutorials and blog posts
Go
5
star
11

mmv

Move multiple files
Go
5
star
12

dev

Quickly initialise development environments
Shell
5
star
13

kombu

🍜 A command-line tool for manipulating tabulated data
JavaScript
4
star
14

nvim

Vim Script
4
star
15

jr-forth

Assembly
3
star
16

focus

CLI app which temporarily blocks websites
Go
2
star
17

sudoku

A quickly written sudoku solver in golang
Go
2
star
18

Flower-App

Java
2
star
19

guestbook

📖 A simple web analytics server
Go
2
star
20

865

RFC 865 — Quote of the day
C
2
star
21

do-yoga-with-me-index

🧘‍♀️ An index of videos hosted on
HTML
2
star
22

learning-rust

Rust
2
star
23

spell-check-trie

A spell-check algorithm using tries
HTML
2
star
24

advent-of-code

Python
1
star
25

dot-config

👩‍🔬 My configuration files
Vim Script
1
star
26

jamesandrosie.wedding

HTML
1
star
27

santoku

C
1
star
28

l-system-starter-pack

A starter pack repo for an Enthusiasticon '18 workshop on L-Systems
HTML
1
star
29

collected-articles

A reading list
1
star
30

exclude

🏎 Remove rows in file X from file Y, quickly
Go
1
star
31

Flower-Classification

Python
1
star
32

terrazzo

JavaScript
1
star