3 ms·
I thought that most of the time since users are typing one character at a time that would be efficient. Even pasting at the end of the string is easy to manage
by sunir 16y ago
I thought that most of the time since users are typing one character at a time that would be efficient. Even pasting at the end of the string is easy to manage as it might only be O(q) where q is the length of the query string (depending on the structure of the underlying trie).
The worst cases are editing midstring, and worst, pasting to the start of the query string. Still, those are O(q) rather than O(N) where N are the total number of strings in the database. In my case, N will have millions of records where q will rarely exceed 250 characters.
- whakojacko 16y agothe problem is not efficiency, its relevancy. Say you have a result "hacker news". If its a pure prefix trie, this wont match the query "news", even though you probably want to return this as a suggestion. My hack around this would be to add both "hacker news" and "news" in the trie-Its still not perfect, since it wouldn't match "acker" or "ws" etc.