简体   繁体   English

(非压缩)特里的用途

[英]Uses of (non-compressed) Trie

I'm studying various "prefix-lookup" data structures, such as Tries and Radix Tries (Patricia Tries). 我正在研究各种“前缀查找”数据结构,例如Tries和Radix Tries(Patricia Tries)。

At this point, I have a solid understanding of both tries and radix tries, as well as a good understanding of their use cases. 在这一点上,我对try和radix try都有扎实的了解,并对它们的用例也有很好的了解。

However, one question jumps out at me: is there any advantage to using a regular trie over a compressed trie (such as a radix trie)? 但是,一个问题突然浮出水面:与压缩的Trie(例如基数Trie)相比,使用常规Trie有什么好处吗?

A regular trie is simple to implement: it stores one character per node. 常规树很容易实现:每个节点存储一个字符。 A Patricia Trie is a bit more difficult to implement: it is "compressed" in the sense that each node contains an entire string, and prefix comparisons are done using bitwise matching. Patricia Trie的实现有点困难:从每个节点包含整个字符串的意义上讲,它是“压缩的”,并且前缀比较是使用按位匹配完成的。

Since a Patricia Trie is more space efficient, and doesn't sacrifice lookup speed, is there any use case for using a regular (non-compressed) Trie where every node contains a single letter? 由于Patricia Trie更加节省空间,并且不牺牲查找速度,是否存在使用每个节点都包含一个字母的常规(非压缩)Trie的用例?

The only use case I can think of is if your "strings" are something other than regular strings of characters (like arrays of more complex objects), and therefore cannot be compared using bit by bit comparisons. 我能想到的唯一用例是,您的“字符串”不是常规的字符串(例如,更复杂的对象的数组),因此无法使用逐位比较进行比较。

Is there any other use case for a regular (non-compressed) Trie? 常规(非压缩)Trie是否有其他用例?

最有可能的是,插入压缩的特里树太昂贵了。

i'm guessing they are just easier to understand and make analysis/design of algorithms easier. 他们只是更容易理解,并使算法的分析/设计更容易。 So they are perfect for educational purpose before compressed trees are introduced 因此,在引入压缩树木之前,它们非常适合用于教育目的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM