retagged by
6,417 views
9 votes
9 votes
  1. Find recurrence relation for ternary string of length n that do not contain two consecutive zeros or two consecutive 1s?
  2. Find recurrence relation for ternary string that contain either two consecutive or two  consecutive 1s?
  3. Find recurrence relation for no of ternary strings of length n that do not contain two consecutive symbols same?
  4. Find recurrence relation for ternary strings of length n that  contain two consecutive symbols same?


Also write initial conditions.

retagged by

3 Answers

Best answer
7 votes
7 votes
1. Let $a_{n}$ be the no. of ternary strings not containing "00" or "11" of length $n$. Let $a_{0_{n}}$ be the no. of ternary strings not containing "00" or "11" of length $n$ and ending in '0' and similarly we define $a_{1_n}$ and $a_{2_{n}}$. So,

$$\begin{align*} a_{n} &= a_{0_{n}} + a_{1_n} + a_{2_{n}}  \\
&= \left(a_{1_{n-1}} + a_{2_{n-1}}\right) + \left(a_{0_{n-1}}+a_{2_{n-1}}\right) + \left(a_{0_{n-1}} + a_{1_{n-1}} + a_{2_{n-1}}\right)\\
&= 2. \left(a_{0_{n-1}} + a_{1_{n-1}} + a_{2_{n-1}}\right) + a_{2_{n-1}}\\
&= 2.a_{n-1} + a_{n-2}. \end{align*}$$
For initial condition, $a_1 = 3, a_2 = 7.$(All two length strings except 11 and 00).

2. We can get this as

$$b_n = 3^n - a^n.$$

where $a_n$ is as in 1. Solving, we get

$$\begin{align*}b_n &= 3^n - 2.a_{n-1} - a_{n-2} \\
&= 3^n - 2. \left(3^{n-1} - b^{n-1}\right) - 3^{n-2} + b^{n-2} \\
&= 3^{n-2} \left[ 3^2 - 2.3 - 1 \right] + 2.b^{n-1} + b^{n-2} \\
&= 2. \left(3^{n-2} + b^{n-1} \right) + b^{n-2} \end{align*}$$
Initial condition, $b_1 = 0, b_2 = 2.$

3. Similar to 1, we can write

$$\begin{align*} a_n &= a0_n + a_{1_n} + a_{2_{n}} \\
&= a_{1_{n-1}} + a_{2_{n-1}} + a_{0_{n-1}} + a_{2_{n-1}} + a_{0_{n-1}} + a_{1_{n-1}}\\
&= 2. a_{n-1}. \end{align*} $$
Initial condition $a_1 = 3, a_2 = 6.$

4. $$b_n = 3^n - a_n$$

where $a_n = 2.a_{n-1}$ as shown in 3. Solving we get,

$$\begin{align*} b^n &= 3^n - 2. a_{n-1} \\
&= 3^n - 2. \left(3^{n-1} - b_{n-1}\right). \end{align*}$$
Initial condition $b_1 = 0, b_2 = 3.$
selected by
1 votes
1 votes

Recurrence relation for ternary string of length n

Q.1) that do Not contain two consecutive Zeros or two consecutive Ones
$$t_n = b_n + c_n + d_n$$
where,
$t_n$ = required number of strings
$b_n$ = number of strings that starts with $0$
$c_n$ = number of strings that starts with $1$
$d_n$ = number of strings that starts with $2$

we take this up case by case and observe that :

to get $b_n$ we can simply put a zero in front of $c_{n-1}$ and $d_{n-1}$
so we have $b_n = c_{n-1} + d_{n-1}$
more we can follow from here.

for next set of question which is 3,4: we can follow from here. It can be understood by using simple combinatorics.

–1 votes
–1 votes

1)a1=0,1

  a2=01,10

 a= an-1 +an-2

2) a1=0,1

    a2=00,11

    an= an-1+ an-2

3)a1=0,1

  a2=01,02,10,12,21,20

 a= an-1 +an-2

 

4)a1=0,1

    a2=00,11,22

    an= an-1+ an-2

  

  

edited by

Related questions

0 votes
0 votes
1 answer
3