Taking advantage of alphabetical order in String database search in Java -
i writing java program.
i have thousands of lists stored .txt files. each list contains thousands of words, set in alphabetical order. words in each list different (there no repetitions).
i have search these lists, in order see whether query-word present in each list or not. how can take advantage of alphabetical order make search quicker? brute-force approach (.equals()
method) works takes several hours.
thank in advance help! grateful if send me bits of code.
java provides arrays.binarysearch(object[] array, object key)
, collections.binarysearch(list<? extends comparable<? super t>> list, t key)
methods improve results. they're not optimal solution, they're easy use , better brute force.
Comments
Post a Comment