• retagged by
9,791 views
9 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.

3 Answers

Best answer
7 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 1 vote

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 –1 vote

1)a1=0,1

  a2=01,10

 an = 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

 an = an-1 +an-2

 

4)a1=0,1

    a2=00,11,22

    an= an-1+ an-2

  

  

• edited by
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.3k
1.3k views
aditi19 asked Apr 29, 2019
1,279 views
How many bit sequences of length seven contain an even number of 0s?I’m trying to solve this using recurrence relationIs my approach correct?Let T(n) be the string having...
0 0 votes
0 0 answers
940
940 views
dd asked Mar 19, 2017
940 views
We have two types of shapes.Using these shapes we need to construct $2$*$x$ shapes (height is 2 units and width is $x$ units).For example, all $5$ possible constructions ...
0 0 votes
1 answers 1 answer
555
555 views
2 2 votes
1 answers 1 answer
1.1k
1.1k views
yg92 asked Jan 14, 2017
1,070 views
The recurrence relation for total no of n length English letter words, with even no of a’s.Below is some parts I could build -Assumptions - 26 english letters and no epsi...