Efficiently build a graph of words with given Hamming distance

后端 未结 4 669
情话喂你
情话喂你 2021-02-07 04:08

I want to build a graph from a list of words with Hamming distance of (say) 1, or to put it differently, two words are connected if they only differ from one letter (lo

4条回答
  •  离开以前
    2021-02-07 04:41

    Ternary Search Trie supports Near-Neighbor Searching pretty well.

    If your dictionary is stored as TST then, I believe, average complexity of lookups while building your graph would be close to O(N*log(N)) on real world word dictionaries.

    And check Efficient auto-complete with a ternary search tree article.

提交回复
热议问题