We always have to create 2^(n-1) words, where n is the length of a string. We create all binary numbers consisting of n-1 bits. If there is a 1 in binary number on position j we put space in our word after j-th symbol of word. Time complexity is then O(n * (2^n)).
We always have to create 2^(n-1) words, where n is the length of a string. We create all binary numbers consisting of n-1 bits. If there is a 1 in binary number on position j we put space in our word after j-th symbol of word. Time complexity is then O(n * (2^n)).