Skip to content

Finds all terms beginning with a given prefix, sorted by weight

Notifications You must be signed in to change notification settings

vickiwyang/autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

autocomplete

This program implements autocomplete for a given set of n terms, where a term is a query string and an associated non-negative weight. That is, given a prefix, find all queries that start with the given prefix, in descending order of weight.

Term.java implements the immutable data type Term, which represents an autocomplete search term (a query string with an associated integer weight). Terms can be compared by: 1) lexicographic order of the query string, 2) in descending order by weight, and 3) by lexicographic order of the first r-characters of the query string.

BinarySearchDeluxe.java is a modified implementation of binary search adapted from Bob Sedgewick and Kevin Wayne. firstIndexOf() and lastIndexOf() respectively returns the first and last keys matching the search key in a sorted array.

Autocomplete.java implements the autocomplete functionality for a given set of strings and weights. Search terms are sorted in lexicographic order, then all matching query strings with a given prefix are found via binary search and sorted in descending order by weight.

About

Finds all terms beginning with a given prefix, sorted by weight

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages