TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Introduction to Tries

72 点作者 mriley将近 15 年前

7 条评论

naz将近 15 年前
I've recently been working on directed acyclic word graphs. They are a small modification to tries and can be built with (I think) the same time complexity. For each node, count the distance from EOW when building, maintain a list of nodes with the same EOW distance and merge the ones that are equal strings. They use much less space by sharing suffixes as well as prefixes. <a href="http://en.wikipedia.org/wiki/Directed_acyclic_word_graph" rel="nofollow">http://en.wikipedia.org/wiki/Directed_acyclic_word_graph</a>
carterschonwald将近 15 年前
for an excellent example of a trie implementation, the haskell bytestring trie datastructure is really nice to look at. Its docs can be found at <a href="http://hackage.haskell.org/package/bytestring-trie" rel="nofollow">http://hackage.haskell.org/package/bytestring-trie</a> and the very readable sourcecode at <a href="http://hackage.haskell.org/packages/archive/bytestring-trie/0.2.2/doc/html/src/Data-Trie-Internal.html" rel="nofollow">http://hackage.haskell.org/packages/archive/bytestring-trie/...</a><p>edit: note that its not strictly a trie, but can be used as one, in general its more like it does a trie-like key value lookup.<p>edit: it is also worth noting that its pretty fast, counting reading data in from the file system and other overhead, loading 1.5 million key - value pairs of realworld production data into the trie, and then making my first query, in under 30 seconds. And thats without even doing the sort of preprocessing that can make it much much faster! (namely, lexigraphically sorting the strings I'm using as keys before doing the k-v insertions)
dustrider将近 15 年前
personally I prefer this intro: <a href="http://marknelson.us/1996/08/01/suffix-trees/" rel="nofollow">http://marknelson.us/1996/08/01/suffix-trees/</a><p>or this one which is slightly harder: <a href="http://linux.thai.net/~thep/datrie/datrie.html" rel="nofollow">http://linux.thai.net/~thep/datrie/datrie.html</a>
praptak将近 15 年前
<i>"First, lookup time is O(1) in the size of the trie."</i><p>The article skims over the tricky part - the dependency on the size of the alphabet. Which you can no longer treat as insignificant in the days of unicode.
评论 #1626374 未加载
评论 #1626716 未加载
VolatileVoid将近 15 年前
This is interesting. I wonder if you could use the a similar algorithm for mapping sentences. That is, construct a ternary DAG and keep inserting words (rather than letters) into the trie.
评论 #1626982 未加载
bruceboughton将近 15 年前
How is "trie" pronounced? Like "try"?
评论 #1626503 未加载
lt将近 15 年前
Is it me or there's no RSS in the site?