Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an efficient search algorithm to provide auto-completion?

I've got a list of 10000 keywords. What is an efficient search algorithm to provide auto-completion with that list?

like image 829
Murali Krishna Pinjala Avatar asked Dec 13 '22 23:12

Murali Krishna Pinjala


1 Answers

Using a Trie is an option but they are space-inefficient. They can be made more space effecient by using a modified version known as a Radix Tree, or Patricia Tree.

A ternary search tree would probably be a better option. Here is an article on the subject: "Efficient auto-complete with a ternary search tree." Another excellent article on the use of Ternary Search Tree's for spelling-correction (a similar problem to auto-complete) is, "Using Ternary DAGs for spelling correction."

like image 73
mmcdole Avatar answered May 24 '23 13:05

mmcdole