Let denote the number of bit sequences of length n with an even number of 0's. There are two ways to form a valid string with n bits from a string with one fewer bit. First, a valid string of n digits can be obtained by appending a valid string of n – 1 bits with 1. Hence, a valid string with n bits can be formed in this manner in ways. Second, a valid string of n bits can be obtained by appending a 0 to a string length n – 1 that is not valid. The number of ways that this can be done equals the number of invalid (n – 1)-bit strings. Since there are 2n-1 strings of length n – 1, and are valid, there are valid n-bit strings obtained by appending an invalid string of length n – 1 with a 0. Therefore
for .
Hence, Recurrence relation is
Comments