Here is my soluion . void bipartition(int a[],int p,int max) { if(p==max){return ;}
p++; for(int i=p;i<max;i++) { if(result[i]==1) continue; result[i]=1; print_bipartition(result,a,max); bipartition(a,i,max); result[i]=0; } } void print_bipartition(int result[],int a[],int max) { printf("{"); for(int k=0;k<max;k++) if(result[k]==1) printf("%d ",a[k]); printf("} \t"); printf("{"); for(int k=0;k<max;k++) if(result[k]==0) printf("%d ",a[k]); printf("}\n"); return ; } Can someone help me reduce the time complexity? On Sat, Sep 3, 2011 at 10:07 AM, Siddhartha Banerjee < thefourrup...@gmail.com> wrote: > no of valid bipartitions are 2^n, thats what he meant I guess... ( if you > do not want null set as one of the partitions then subtract 1 from > answer...) > > -- > 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 unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- ........................ *MOHIT VERMA* -- 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.