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 commentsAlso ROPE, a string allowing for prepends, substrings, middle insertions and appends [2]
[0] http://cr.yp.to/critbit.html
[1] https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.96....
[2] https://en.wikipedia.org/wiki/Rope_%28data_structure%29
They are like tries but share prefixes and suffixes of a word corpus, can be built in linear time, and since they are graphs, one can define an inner product between two CDAWGs and use them for kernel-based machine learning algorithms.
https://hal-upec-upem.archives-ouvertes.fr/hal-00620006/docu...
With two unsigned integers, freq and phase, you get amazingly fine control over timing. You only use the top N bits of phase for output. It's saved my bacon in embedded systems more than once.
All comments shown.
Couldn't load more comments. Check your connection and try again.