rec.puzzles Archive

How many n-bit binary strings (0/1) have exactly k transitions (an adjacent pair of dissimilar bits, i.e.,...

combinatorics/transitions

Problem

How many n-bit binary strings (0/1) have exactly k transitions
(an adjacent pair of dissimilar bits, i.e., a 01 or a 10)?
Show solution
A transition can occur at an adjacent pair (i,i+1) where 1<=i<i+1<=n.
Since there are k transitions, there are C(n-1,k) total number of ways
that transitions can occur.  But the string may start with a 1 or a 0
(after which its transitions uniquely determine the string).  So there
are a total of 2C(n-1,k) such strings.