S --> A0 B
A--> BB | 0
B ---> AA |1
We can actually answer this question smartly :D
1)Remove B above.
S --> A0AA | A01
A--> AAAA | AA1 |1AA | 11 | 0
2) S--> A0AA
Try replacing A , Since we need a length 5 string only way we can replace A is
One of the A's replace by 11 and others by 0. ------> 3 ways ( 11000,00110,00011)
3)S-->A01
Try replacing A , Since we need a length 5 string only way we can replace A is by AA1 or 1AA
S-> AA101 | 1AA01 ; Only way to replace A is by A->0
----> 2 ways (00101,10001)
Total=3+2 = 5 strings