Skip to content

linarkou/ClassSearcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClassSearcher

Searcher of last K modified classnames (such as in IDE). This is a solution of a test task.

Problem description

You need to implement the search function of a class by its name. For convenience, You just need to type the first letters of the class name, the IDE offers you a list of K=12 classes that begin with the entered characters. Classes should be sorted by date (last modified at the beginning), if modified at one time - ordered lexicographically. Your task is to implement the selection of class names in the Java language.
It is assumed that data are indexed once, and then searches are fast.
Full description you can find here (in Russian).

Constraints

Count of classes from 1 to 100000.
Class name contains up to 32 characters.
Time of indexing data - few seconds.
Time of query - 300 ms.

Solution

I used a Trie, but in each node I store an ordered set of K=12 last modified classes. So searches by prefix are fast.
In the case of 100000 classnames with same prefix of length=25, building a trie takes 2-3 seconds.

About

Searcher of last modified classnames

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages