问题描述 投票:5回答:1
我有一份CPU型号的清单。现在,我认为最合适的方法是从列表中形成一个 trie,像这样。

现在,我想把一个输入字符串和这个Trie匹配起来 Now, I want to match an input string against this trie. 这对于精确匹配来说很容易,但如果我需要一个模糊的,一个字符串序列可能有遗漏的情况呢?对于 "Intel i3","Core i3 "和 "i3 "要全部匹配到Trie中的 "Intel -> Core -> i -> 3"。

Intel -- Core -- i -- 3
      |       |    |- 5
      |       |    |- 7
      |       |    -- 9
      |       |
      |       -- 2 Duo
      |
      |- Xeon -- ...
      |
      |...

trie是适合这个问题的任务吗?我想过用trie搜索的时候用通配符,但是这里的通配符可以在序列的任何位置。

我可以用什么数据结构来表示列表,以一种最适用于这个问题的方式?我用什么算法进行搜索?

search data-structures string-matching string-search
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.