How to split a string to get all possible partition?

Given a string, how do you split it to get possible paritions?

INPUT:
abc

OUTPUT
a,b,c,
ab,c
a,bc
abc

For a string with length N there must be 2^(N-1) paritions because you can visualize the gaps between each character being present and not present.

Can someone give me the cleanest algorithm for this question? I have a hard time understanding this.

Comments (4)