Assume we have a set of N items say, S = {t1, t2, t3}. I would like to produce all the possible subsets of S given the restriction that t1 must appear in every set. Therefore, all possible subsets of S are {t1}, {t1,t2}, {t1,t3}, and {t1,t2,t3}. How can I write a recursive function that takes two sets {t1} and {t2,t3} and returns the subsets listed above.
Also if I had 100s of subsets such as S, storage of all subsets becomes a problem. My program goes in iterations and at every iteration I only need to manipulate one subset from each set. Is there I way I can produce the subsets of a set in steps rather than all at once? i.e. every time I call next(S), I get a new subset.
Note I'm coding in C.