a) 3323321
b) we can also get the answer of b by solving recurrence relation
T(n) = 2 * T(n-1) +1 ; n>0
= 0 ; n=0 [Since for length zero string no character will be printed]
After solving it by substitution,
T(n) = 2 * T(n-1) +1
= 2 x (2 x T(n-2) + 1 ) +1
= 2^{2 }x T(n-2) + 2 +1
= 2^{2 }x (2*T(n-3) +1 ) + 2 + 1
= 2^{3 }x T(n-3) + 2^{2 }+ 2 + 1
Finally it will expand like
= 2^{n }x T(n-n) + 2^{n-1} + 2^{n-2} + - - - - - - - + 2^{2 }+ 2 + 1
= 2^{n }x T(0) + 2^{n-1 }+ 2^{n-2 }+ - - - - - - - - - - + 2^{2 }+ 2 + 1
= 1x (2^{n }-1) / (2 - 1 )
= 2^{n }-1