Welcome to the Autocomplete assignment. In this assignment, you will be implementing the autocomplete algorithm, which is discussed at length here, using binary search and trie traversal. In doing so, you will see some of the advantages of using tries (or more generally, trees/graphs) and sorted arrays over general arrays.
As always, before starting be sure to snarf the assignment via Ambient so you can read along. You can alternatively download the .jar file here.
You can also view/download the individual classes:
Here is a printer friendly version of this assignment.
###Introduction
In this assignment, you will implement autocomplete for a given set of N terms, where a term is a query string and an associated nonnegative weight. That is, given a prefix, find all queries that start with the given prefix, in descending order of weight.w
For example, if I am given the query “com” I might suggest terms like “computer”, “communication” or “combine”. For this assignment, our terms have predetermined fixed weights assigned to them, and we will return the highest-weighted terms among those terms that share have the query as their prefix.
In this assignment, you will:
Term
that represents an autocomplete
term: a query string and an associated real weight.
BinarySearchAutocomplete
that impletements autocomplete
functionality by using binary search
to find the all query strings that start with a given prefix; and sort the
matching terms in descending order by weight.
TrieAutocomplete
to implement
Autcocomplete functionality using a Trie data structure.
</ol>
When you snarf this project, you will receive the following already completed classes:
Autocompletor
– the interface which you will be writing implementations of.AutocompleteMain
– the class to launch the GUI from. When testing your implementations of autocomplete, you will need to change the String AUTOCOMPLETOR_CLASS_NAME’s value.AutocompletorBenchmark
– once you have written an implementation of Autocompletor, this class will tell you how quickly it runs.BruteAutocomplete
- A completed (albeit slow) implementation of Autocompletor. Node
– a node class for use in TrieAutocomplete. Nothing needs to be modified here, but definitely read through this class before starting TrieAutocomplete.AutocompleteGUI
–
the GUI for this project. You can ignore this class.Term
– a class used to encapsulate individual search terms and their weights, which includes several methods of comparing terms. You need to complete these class in order for BruteAutocomplete to be usable with AutocompleteMain.BinarySearchAutocomplete
– an implementation of Autocompletor which performs the autocomplete algorithm using binary search.TrieAutocomplete
– an implementation of Autocompletor which performs the autocomplete algorithm using trie exploration.Autocompletor
implementations:
TestTerm
,
TestBinarySearchAutocomplete
,
and TestTrieAutocomplete
to test the
correctness; andAutocompleteBenchmark
to analyze the efficiency.