Fast set indexing data structure for superset retrieval

Posted by Asterios on Programmers See other posts from Programmers or by Asterios
Published on 2012-11-12T10:40:03Z Indexed on 2012/11/12 17:19 UTC
Read the original article Hit count: 324

Filed under:
|

I am given a set of sets:

{{a,b}, {a,b,c}, {a,c}, {a,c,f}}

I would like to have a data structure to index those sets such that the following "lookup" is executed fast: find all supersets of a given set.

For example, given the set {a,c} the structure would return

{{a,b,c}, {a,c,f}, {a,c}}

but not {a,b}.

Any suggestions? Could this be done with a smart trie-like data structure storing sets after a proper sorting?

This data structures is going to be queried a lot. Thus, I'm searching for a structure that might be expensive in build but rather fast to query.

© Programmers or respective owner

Related posts about data-structures

Related posts about indexing