Ask HN: What are some cool but obscure data structures you know about?
11–20 of 772 posts
Re: Ask HN: What are some cool but obscure data structures you know about?
#12When I go from Haskell back to imperative land I find myself greatly missing this ability. Sure I can make multiple hashmaps or trees or whatever but being able to stuff it all in one data structure is amazing.
One structure I built with them that is much more difficult with typical structures is a "block list" structure.
In this structure each block has a particular width and they're all stacked side by side.
I want to perform a query, "which box is at position X". So if my boxes are of widths 7,20,10, then the lookup for 2 yields the first box, the lookup for 12 yields the second, etc.
More interestingly, if add a new box between the second and third, the indices covered by the last box is increased.
With finger trees you use a sum monoid. This is easy. In other languages you have to roll your own structure either using a list (with o(n) lookup) or a tree with o(log n) lookup, but o(n) inserts (to translate the indices of future blocks)
Re: Ask HN: What are some cool but obscure data structures you know about?
#13Re: Ask HN: What are some cool but obscure data structures you know about?
#14The Israeli queue. Like a regular queue, but if something new that comes in sees its friend in the queue already, it can jump the queue and go and stand next to her. Useful for when something has a big overhead on top of its own processing, but the overhead can be shared between several similar entries. If you're doing it anyway for the one already in the queue, you get to make the most of it for its friends too. I c…
Re: Ask HN: What are some cool but obscure data structures you know about?
#15The canonical use case for HLL is counting unique visitors. But any large dataset where you only need a good approximation is a valid target :)
Re: Ask HN: What are some cool but obscure data structures you know about?
#16Monotonic stacks are neat. I made up a data structure once, consisting of a pyramid of deques. It lets you efficiently compute any associative function over a streaming window of data.
I feel like they're quite possibly the most deceptively simple data structure I've yet to encounter. That is to say that for me at least there was/is a wide gulf between simply understanding what the data structure is (doesn't get much simpler than a stack!) and when/how to actually apply it.
Re: Ask HN: What are some cool but obscure data structures you know about?
#17Re: Ask HN: What are some cool but obscure data structures you know about?
#18https://en.m.wikipedia.org/wiki/R-tree
Also concurrent data structures.
Re: Ask HN: What are some cool but obscure data structures you know about?
#19Tries (or prefix trees). We use them a lot at Pyroscope for compressing strings that have common prefixes. They are also used in databases (e.g indexes in Mongo) or file formats (e.g debug symbols in macOS/iOS Mach-O format are compressed using tries). We have an article with some animations that illustrate the concept in case anyone's interested [0]. [0] https://github.com/pyroscope-io/pyroscope/blob/main/docs/sto..…
https://leetcode.com/discuss/general-discussion/931977/begin...
Re: Ask HN: What are some cool but obscure data structures you know about?
#20The Israeli queue. Like a regular queue, but if something new that comes in sees its friend in the queue already, it can jump the queue and go and stand next to her. Useful for when something has a big overhead on top of its own processing, but the overhead can be shared between several similar entries. If you're doing it anyway for the one already in the queue, you get to make the most of it for its friends too. I c…