How to create a simple prefix index in Java?

后端 未结 4 381
Happy的楠姐
Happy的楠姐 2020-12-19 13:01

I have big set of urls and I want to implement an autocompletion. I don\'t like the complexity of the naive approach as it is linear with the set size:

for(S         


        
4条回答
  •  星月不相逢
    2020-12-19 13:26

    A great alternative algo is a ternary search tree (more memory efficient) https://github.com/varunpant/TernaryTree/tree/master/TernaryTree

    here is a trie in java http://algs4.cs.princeton.edu/52trie/TrieST.java.html

提交回复
热议问题