I have to choose one data structure for my need below i am explaining the conditions there are following values
abc,def,rty,ytr,dft which all are map to row R1B1 (actully key is combination of R1+B1)
abEERc,dFFFef,rGGty which all are map to row R1B2 (actully key is combination of R1+B2)
KEY VALUE
abc,def,rty,ytr,dft ---> R1B1
abEERc,dFFFef,rGGty ---> R1B2
now, for example, let's say, if i get ytr
then i would be able to retrieve R1B1
or, let's say, i get the value rGGty
then i would be able to retrieve R1B2
now the case is that matters is of search, complexity and the time taken as the things have to go in sequence
for example, it will first pick the first line to search ytr
, it will first match it with abc
which will not match then will have to match with def
it will not again match then it will match with rty
which will not also match then it will finally match with ytr
and finally it will find the key R1B1
finally
similarly if the second string need to be searched lets say rGGty
then it would scan first row in which it will not find the value then search would continue to second row and also in second row in the third element it would get rGGty
as element then it would retrieve R1B2
as value
let's say, if put this thing in map then a sequence search will go on key and then only we will be able to find the corresponding value
Folks please advise which will be the best data structure i can implement in java in which i will have to search the keys items to find the corresponding value in very fast time also which will not hit the performance too ,the kind of data structure performance should be very high
Please advise folks also it would be great if some one can advise me to show how this can be achieved using digital trees
As the comments suggest you can simply use a HashMap or HashTable,
if you insist on implementing a structure on your own i would suggest a search trie.
In a search trie the number of maximum comparisons required to retrieve data is equal to the length of the key used, so to retrieve data for the given keys(abc,def,rty,ytr,dft) exactly 3 comparisons would be required
Consider the following wikipedia link: https://en.wikipedia.org/wiki/Trie
Also below is my quick and dirty implementation of a search trie (provided the keys are standard ASCII letters) :)-