“前缀列表”的名称数据结构? [英] Name for a "prefix list" data structure?

查看:163
本文介绍了“前缀列表”的名称数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的数据结构寻找一个好的名字,它包含一个列表的所有启动子列表,例如:

 给定列表:[A,B,C] 
我的数据结构:[[A],[A,B],[A,B,C]]
<请注意,我的数据结构只包含有序组合(例如,不是 [C,B,A] ),不包括所有组合(例如,不是 [B,C] )。只有所有的前缀(以某种方式)。



这种数据结构是否有正确的数学/编程术语?

解决方案

使用 TRIE 。您可以在互联网上的资源上阅读有关此数据结构的更多信息。



如果我们想要两个操作,查找和前缀搜索, Trie 是适合的。它主要用于字典和拼写检查。使用 Trie ,我们可以支持所有操作,如插入,搜索,删除在 O(n)时间,其中n是长度要处理的字。



Trie的另一个优点是,我们可以按字母顺序打印所有单词。



使用Trie的缺点是它使用更多的内存。要解决这个问题,您可以阅读有关三元搜索树


I'm looking for a good name for my data structure, which holds all the "starts-with" sub lists of a list, e.g.:

Given list: [A, B, C]
My data structure: [ [A], [A, B], [A, B, C] ]

Note that my data structure does include only ordered combinations (e.g., not [C, B, A]) and does not include all combinations (e.g., not [B, C]). Only all the prefixes (in a way).

Is there a correct mathematical/programming term for this kind of data structure?

解决方案

Use TRIE. You can read more about this data structure on resources available on internet.

If we want both operations, look up and prefix search, Trie is suited. It is mostly used in Dictionary and Spell Checker. With Trie, we can support all operations like insert, search, delete in O(n) time where n is length of the word to be processed.

Another advantage of Trie is, we can print all words in alphabetical order.

Disadvantage of using Trie is it uses more memory. To work on that you can read about Ternary Search Tree

这篇关于“前缀列表”的名称数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆