Ask HN: What are some cool but obscure data structures you know about?
2051 pointsI'll start: bloom filters. Lets you test if a value is definitely NOT in a list of pre-stored values (or POSSIBLY in a list - with adjustable probability that influences storage of the values.)
Good use-case: routing. Say you have a list of 1 million IPs that are black listed. A trivial algorithm would be to compare every element of the set with a given IP. The time complexity grows with the number of elements. Not so with a bloom filter! A bloom filter is one of the few data structures whose time complexity does not grow with the number of elements due to the 'keys' not needing to be stored ('search' and 'insert' is based on the number of hash functions.)
Bonus section: Golomb Coded Sets are similar to bloom filters but the storage space is much smaller. Worse performance though.
Comments (753) 253 threads
Earlier comments[1] https://en.wikipedia.org/wiki/Count–min_sketch
[2] https://www.youtube.com/watch?v=kx-XDoPjoHw
So good forward error correction that up toa few years ago it was all under patents.
Gold Codes (2) are also very cool in CDMA systems.
[1] https://en.m.wikipedia.org/wiki/Low-density_parity-check_cod...
[2] https://en.m.wikipedia.org/wiki/Gold_code
Think of them as double ended priority queues. O(n) construction with O(lgN) mutations. Both the min and max elements are quick to get O(1).
The paper is short and the data structure is elegant. I read it a few years ago in uni and made me appreciate how greatly useful can be implemented very simply.
https://dl.acm.org/doi/pdf/10.1145/6617.6621
If you like these kinds of data structures, the Database Internals [3] book has a good introduction and explanation of a handful of BTree optimizations like this.
1: https://www.microsoft.com/en-us/research/wp-content/uploads/...
2: https://www.cs.cmu.edu/~huanche1/publications/open_bwtree.pd...
3: https://www.databass.dev/
All comments shown.
Couldn't load more comments. Check your connection and try again.