Best way to structure data for efficient searching

Asen Bozhilov asen.bozhilov at gmail.com
Thu Mar 29 10:04:35 EDT 2012


Larry.Mart wrote:
> Since there are duplicates, I can't use a dict. And if I have any
> extraneous data in the keys (i.e. something to make them unique) then
> I still have to walk through the entire dict to find the matches.

You can use slightly different approach. With double mapping you could
simplify the lookup. What I mean?
Get the first set and build lookup map as:
MAP := {
 KEY1-VALUE : {
 KEY2-VALUE : [SET, SET, n-th duplicate SET]
 }
}
In the worst case you would have quadratic complexity of the
algorithm. Otherwise the lookup would be really fast.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /