This is a simple version of typeahead implemeted in java using Trie.
Typeahead is a feature of software, website or application(and some typewriters) that enables users to continue typing and keep receiving hottest keyowrds based on what they are typing as the prefix of those keyowrds.
This version of typeahead supports build, search, serialization and deserialization.
Build method is called to build a Trie based on what we got from original data, which could be tens of thounsand items of data logs from some search engine.
Usually, the log looks like:
KEYWORD | FREQUENCY
apple 10
amazon 15
intel 4
cisco 13
app 25
walmart 14
apex 10
adobe 24
alibaba 32
Keyword is the top K hottest keywords that is searched in a regular period of time.
Frequency is how many times a keyowrd is searched.
This simple version of typeahead converted above log information into a trie.
Search will return a list of hottest keyowrds that users may want to type.
Serialization and deserialization is used to store/recover trie into/from file and disk.