Printing powerset of characters is somewhat easy. Here the key point is to understand that for a given number of n characters we will have (2^N)-1 combinations. We will then count thru integers starting from 1 to (2^N)-1 and then check the bit set on the integer and accordingly the same element will be printed from the character array.
Below is the C implementation of this interesting program :
No comments:
Post a Comment