My problem is let suppose my dataset is {A,B,C,D,E}
and suppose my partition size is (2,3)
Result would be
(A,B) (C,D,E)
(A,C) (B,D,E)
(A,D) (C,B,E)
(A,E) (B,C,D)
(B,C) (A,D,E)
(B,D) (A,C,E)
(B,E) (A,C,D)
(C,D) (A,B,E)
(C,E) (A,B,D)
(D,E) (A,B,C)
I need to print all the possible combinations for the partition size provide...The partition size could be(1,4) also...

Please help me out with the logic. Thanks

What you need is all combinations of the set. Then the break down is done after you have all the combinations. If you notice how each element arranges in the solution, you would know what I mean.

Now, a link solution and explanation about how a combination works is at this one You could see how it is done in various languages. Also, other people posted about disadvantages of each technique. Please do not just copy and paste the code portion you want but read everything on the page. It is very useful for you in the future.