Recommended data structure when developing something like a dictionary?

Is TRIE the most recommended data structure when developing something like a dictionary for storing words? Any other alternatives that improve memory time or performance?

I believe that a hash can be good if there is no collision, but then the memory requirements start to become bad for overlapping words: overlap, overlap, overlap, overlap, overlap all occupy exceptional storage, while we could share the space in trie .

EDIT: Thanks to @Moron and all of you for the very helpful answers. I agree - hash key generation is O (n), as well as TRIE search. However, it can be worse for hash things when the chain adds time, but for TRIE this will not happen. My concern is that for each node in TRIE I need to hold a pointer that can blow if the dictionary size is small.

+3
source share
3 answers

You can try the Acyclic Word Directional Graph , which is basically trie but has better memory usage and, according to the wiki, for English, memory consumption is much lower than trie's.

, , , , . , O (logn) . O (n) , n - .

+2

:

  • trie O(m) -. - . - -, -. - - O(N), O(1), O(m) , .
  • trie .
  • trie, -, , , .
  • - -, trie .
  • Trie .

:

  • , - , , .
  • , - , .

- , , trie.

: : Trie #

+5

I think this is a big question, huh? Maybe try a look at the Bloom filter?

http://en.wikipedia.org/wiki/Bloom_filter

0
source

Source: https://habr.com/ru/post/1753574/


All Articles