i want to determine al possible subsets from a given set( it may be integers or chars) using recursion only.....
can some1 help me in making an algo for it???
Printable View
i want to determine al possible subsets from a given set( it may be integers or chars) using recursion only.....
can some1 help me in making an algo for it???
Homework? You probably won't get much help here unless you show that you've made a step towards trying to solve it yourself. Post some code. Tell us where your problems are. We'll help.
lolzz yups its a homework....i just want to get an idea how to start it....rest i can do it myself...
Hint: suppose your set is A = {a1, a2, ..., aN}. Suppose P(A) is the set of all subsets of A.
Then P(A) = subsets of A that don't have a1 + subsets of A that do have a1, or:
P(A) = P(A\{a1}) + {B+{a1} : B in P(A\{a1})},
where A\{a1} is the set you get when you remove the element a1 from A and + is the union of two sets.
This suggests an obvious recursive algorithm.
thanx man!!!