Let a finite sequence of values be called discrete-continuous if the following conditions hold:
Thus, while 0, 1, 1, 0, -1 is discrete-continuous, 0, 1, -1, 0, 1 is not. Find the number of discrete-continuous sequences of length 7.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
We solve the problem for sequences of length n .
First, add a zero to the front and to the end of the sequence. Now write between each pair of successive digits whether they remain the same ( = ) or are different ( ⋆ ). Thus, ( − 1 , 0 , 0 , 1 , 1 , 0 , 1 ) ↦ ( 0 ⋆ − 1 ⋆ 0 = 0 ⋆ 1 = 1 ⋆ 0 ⋆ 1 ⋆ 0 ) . It is easy to check that we have n + 1 symbols; and that the number of stars is even.
Consider the sequences with 2 k stars (and n + 1 − 2 k equal signs). There are ( 2 k n + 1 ) ways to place the star. Every other star represents a jump from zero to either + 1 or − 1 . There are 2 k ways to choose these signs. Thus there will be 2 k ( 2 k n + 1 ) sequences with 2 k stars.
The total number of sequences is therefore S ( n ) = k = 0 ∑ ⌊ ( n + 1 ) / 2 ⌋ 2 k ( 2 k n + 1 ) .
It is not difficult to see, using the binomial theorem, that this may be written as S ( n ) = 2 ( 1 + 2 ) n + 1 + ( 1 − 2 ) n + 1 = [ 2 1 ( 1 + 2 ) n + 1 ] . (Here, [ ⋅ ] stands for rounding to the nearest integer.)
For n = 7 , we find S ( n ) = ( 0 8 ) + 2 ⋅ ( 2 8 ) + 4 ( 4 8 ) + 8 ⋅ ( 6 8 ) + 1 6 ⋅ ( 8 8 ) = 1 + 5 6 + 2 8 0 + 2 2 4 + 1 6 = 5 7 7 ; or S ( n ) = [ 2 1 ( 1 + 2 ) 8 ] = [ 5 7 6 . 9 9 9 5 7 ] = 5 7 7 .
Recursive solution
Let S ( n ) be the number of sequences of length n and S x ( n ) the number of these sequences ending in x . Then S 0 ( n ) + S − 1 ( n ) + S + 1 ( n ) = 0 ; S − 1 ( n ) = S + 1 ( n ) . We make a sequence of length n by adding a digit to a sequence of length n − 1 :
Combining this, we see that S ( n ) = S 0 ( n − 1 ) + 2 S ( n − 1 ) = 2 S ( n − 1 ) + S ( n − 2 ) . To solve this recursion equation, we try S ( n ) = α p n and obtain p 2 − 2 p − 1 = 0 . The solutions are p = 1 ± 2 ; thus we set S ( n ) = α ( 1 + 2 ) n + β ( 1 − 2 ) n , and with S ( 0 ) = 1 , S ( 1 ) = 3 we easily find α = β = 2 1 .