TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What is your favorite data structure, what have you done with it?

16 pointsby semicolondevover 9 years ago
Would like to check out and learn from practical and interesting implementations of data structures

3 comments

tptacekover 9 years ago
Aguri tries, which are bounded-sized radix trees with an LRU aggregation rule of joining sibling nodes.<p>The motivating use case is tracking metrics for IP addresses. You insert individual IP addresses into the tree, and when the tree fills, it starts rolling nodes for &#x2F;32s into &#x2F;31s, &#x2F;30s, &amp;c. Eventually, you get a picture of ranges of IP addresses in the data. That&#x27;s neat, because, of course, IP packets themselves don&#x27;t tell you anything about what subnets their IP addresses belong to.<p>The goofy thing I&#x27;ve done with them is apply them to memory addresses, so that I can collect individual pointers and bubble them up into allocation ranges, without instrumenting allocators.
评论 #10329583 未加载
评论 #10325049 未加载
bltover 9 years ago
I like when a simple data structure works in harmony with a simple algorithm to get really good performance. Like the algorithm would be completely mediocre if you replaced the data structure with something naive, but the data structure &quot;unlocks&quot; it and makes it fast:<p>- union-find data structure in Kruskal&#x27;s minimum-spanning-tree algorithm, or for labeling connected components in binary images<p>- min-heap in Dijkstra&#x27;s single-source-shortest-paths algorithm<p>- trie in the Apriori frequent-itemset data mining algorithm<p>Spatial partition data structures like octrees and kd-trees are really cool. Useful for anything that simulates physical space like games, graphics, CAD systems. Never implemented one myself though.<p>Least favorite is the red-black tree. It has nice theoretical properties but is so ugly and complicated. Most times I&#x27;ve thought about using one, I ended up choosing a hash table, trie, or sorted array instead. If I ever really need all its properties, I&#x27;ll go all the way and use a b-tree for its cache friendliness.
dropit_sphereover 9 years ago
A simple data structure (tree), but the process of laying it out for visualization (the Reingold-Tilmann algorithm) is more complex than you&#x27;d think.<p>But otherwise, I am the datastructure equivalent of a Blubber programmer :(.