Software Engineering
1 post
10 min read
Implementing Autocomplete in C++ with Tries and Ternary Search Trees
Autocomplete relies on data structures that can find words by prefix efficiently. This article compares tries and ternary search trees and shows how to implement both approaches in C++.
How Prefix-Based Autocomplete Works
Autocomplete is the feature when an application predicts the complete word, after just typing some prefix of the word. You must have used autocomplete feature a lot in your life in many area like:
- Search engines, Google search engine suggests to you an autocomplete feature when you type some text in the search bar, usually sorted by most trends.
- Emails, as you start writing some prefix of the Email address you will get a list of suggestions.
- Social media, like facebook, linkedin, instagram…
- In source code editors, actually I am using Atom right now and I have used autocomplete for at least 10 times just in the first small part of this article.