I found a link online that shows an algorithm to generate all combinations of a string: http://www.mytechinterviews.com/combinations-of-a-string
Algorithm is copied belo
It balances the first line of the loop body, restoring outstr to what it was at the top of the loop body (by removing the character from instr that was appended).