GeistHaus
log in · sign up

How to implement a hash table (in C)

benhoyt.com

An explanation of how to implement a simple hash table data structure, with code and examples in the C programming language.

3 pages link to this URL
Writing a Hash Table in Go

Writing a Hash Table in Go Inspired by the recent post from Ben Hoyt, a recent refresher of Computer Science fundamentals and my journey on learning the Go programming language, I’ve implemented a hash table in Go. Hash Table is a great data structure, they are to Balanced Trees what linear time sorting is to comparison sorts. By not relying on the comparison model, they allow you go below the log n lower bound for searching provided by Balanced Trees. Hash Tables allow you to do constant time look-ups and amortized constant time addition and deletion. This means that adding and deleting items will take mostly O(1), but some operations might take a little longer (i.e. O(n) for rehashing). This isn’t a big problem though, as we will see later in this post, if we choose our strategies well, we can assume that this won’t happen very often and for most operations we will run in constant time.

0 inbound links article en post gohashtablescratchGoHashtableScratch