English 中文(简体)
建议的数据结构,同时设计像字典这样的内容?
原标题:recommended data structure while designing something like a dictionary?

在设计像字典这样的字典以储存字面时,TRIIE是否是最推荐的数据结构? 任何其他改进时间或记忆性能的办法?

我认为,如果不发生碰撞,那么记忆要求就会变得不好,因为重复的话:在重叠、重叠、重叠、重叠、重叠和重叠的情况下,所有这些都占据了独一无二的储存,而我们可以在三角地分享空间。

EDIT: 感谢@Moron,并感谢你所作的非常有益的回答。 我同意——生成散射钥匙是O(n) ,也是一种TRIE搜索。 然而,由于链条加起来,随着时间的推移,而对于跨国激进党来说,这种情况不会发生。 我仍然关切的是,对于跨国激进党的每一个节点,我需要保持一个点,如果独裁者的规模很小的话,可能会对事情进行打击。

最佳回答

http://en.wikipedia.org/wiki/Directed_acyclic_word_graph”rel=“nofollow noreferer” 参考书目: 记忆的消耗量基本是微不足道的,但记忆的使用较好,根据维基,对于联合国来说,记忆的消耗量远远低于微不足道。

时间是明智的,好像是微不足道的,可能比过去好。 不能确定你去奥(logn)的时间。 如果是所搜索的字长,那就应当是O(n)。

问题回答

三个小组拥有以下优势:

  1. Looking up data in a trie is faster in the worst case, O(m) time, compared to an imperfect hash table. An imperfect hash table can have key collisions. A key collision is the hash function mapping of different keys to the same position in a hash table. The worst-case lookup speed in an imperfect hash table is O(N) time, but far more typically is O(1), with O(m) time spent evaluating the hash.
  2. There are no collisions of different keys in a trie.
  3. Buckets in a trie which are analogous to hash table buckets that store key collisions are only necessary if a single key is associated with more than one value.
  4. There is no need to provide a hash function or to change hash functions as more keys are added to a trie.
  5. A trie can provide an alphabetical ordering of the entries by key.

特里斯有以下缺点:

  1. Tries can be slower in some cases than hash tables for looking up data, especially if the data is directly accessed on a hard disk drive or some other secondary storage device where the random access time is high compared to main memory.
  2. It is not easy to represent all keys as strings, such as floating point numbers - a straightforward encoding using the bitstring of their encoding leads to long chains and prefixes that are not particularly meaningful.

如果这些缺陷是你能够生活的东西,我建议说这三重。

资料来源:





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签