Re: [algogeeks] Re: How to find power set of a subset.

2011-07-18 Thread Anantha Krishnan
Recursive approach : - The set of subsets of {1} is {{}, {1}} - For {1, 2}, take {{}, {1}}, add 2 to each subset to get {{2}, {1, 2}} and take the union with {{}, {1}} to get {{}, {1}, {2}, {1, 2}} - Repeat till you reach n Iterative Approach

Re: [algogeeks] Re: How to find power set of a subset.

2011-07-18 Thread ankit sambyal
We can't solve this problem better than O(2^n) because a power set contains 2^n subsets and we have to print all the subsets. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To

[algogeeks] Re: How to find power set of a subset.

2011-07-18 Thread saurabh singh
Efficient recursive approaches are also welcome. On Mon, Jul 18, 2011 at 8:47 PM, saurabh singh wrote: > Excuse for the trivial question.I am trying to design an iterative approach > for the same. > My best shot has been. > #include > #include > using namespace std; > void printset(char a[],bits