Find a recurrence relation for the number of ternary strings of length n that do not contain two consecutive...
$begingroup$
Note: Problem from "Kenneth Rosen's DM and it's applications" and solution from "Students solution guide for use with ... applications"
Let P(n) be the number of strings not containg two containing two consecutive zeros or two consecutive ones.
I got the answer
P(n)=P(n-1)+2P(n-2)+2P(n-3)+...+2P(0) +2
but then the book says the sequence also satisfies the recurrence relation
P(n)=2P(n-1)+P(n-2). I am not able to understand this part.
combinatorics discrete-mathematics recurrence-relations
$endgroup$
add a comment |
$begingroup$
Note: Problem from "Kenneth Rosen's DM and it's applications" and solution from "Students solution guide for use with ... applications"
Let P(n) be the number of strings not containg two containing two consecutive zeros or two consecutive ones.
I got the answer
P(n)=P(n-1)+2P(n-2)+2P(n-3)+...+2P(0) +2
but then the book says the sequence also satisfies the recurrence relation
P(n)=2P(n-1)+P(n-2). I am not able to understand this part.
combinatorics discrete-mathematics recurrence-relations
$endgroup$
add a comment |
$begingroup$
Note: Problem from "Kenneth Rosen's DM and it's applications" and solution from "Students solution guide for use with ... applications"
Let P(n) be the number of strings not containg two containing two consecutive zeros or two consecutive ones.
I got the answer
P(n)=P(n-1)+2P(n-2)+2P(n-3)+...+2P(0) +2
but then the book says the sequence also satisfies the recurrence relation
P(n)=2P(n-1)+P(n-2). I am not able to understand this part.
combinatorics discrete-mathematics recurrence-relations
$endgroup$
Note: Problem from "Kenneth Rosen's DM and it's applications" and solution from "Students solution guide for use with ... applications"
Let P(n) be the number of strings not containg two containing two consecutive zeros or two consecutive ones.
I got the answer
P(n)=P(n-1)+2P(n-2)+2P(n-3)+...+2P(0) +2
but then the book says the sequence also satisfies the recurrence relation
P(n)=2P(n-1)+P(n-2). I am not able to understand this part.
combinatorics discrete-mathematics recurrence-relations
combinatorics discrete-mathematics recurrence-relations
asked Jun 12 '15 at 15:34
lapinlapin
134210
134210
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
$$P(n-1)=P(n-2)+2P(n-3)+dots+2$$
So
$$P(n)-P(n-1)=P(n-1)+P(n-2)$$
$endgroup$
add a comment |
$begingroup$
You can think about it like this: start with a string of length $n-1$. It's last character is $xin {0, 1, 2}$. If $x=0$ or $x=1$, then you have $2$ choices for how to finish (either ${1, 2}$ if $x=0$ or ${0, 2}$ if $x=1$). If $x=2$ then we have $3$ choices for how to finish: ${0, 1, 2}$. Let's think about what the end of strings look like. I'll let $x_{0}$ denote that the $n-1$st element is a $0$, $x_{1}$ to denote that the $n-1$st element is a $1$ and $x_{2}$ to denote that the $n-1$st element is a $2$. Strings could end in any of the following ways:
$x_0 1$
$x_0 2$
$x_1 0$
$x_1 2$
$x_2 2$
$x_2 1$
$x_2 0$
Note that if I group the first 6 of these, I have counted $2P(n-1)$ strings; this is because every one of the strings of length $n-1$ either ends in a $0$, $1$ or a $2$ and I've counted each of those occurrences twice. And, I still need to count the strings that end in $x_2 0$ (or the last two digits are $2,0$). The number of ways to end in $2,0$ is precisely $P(n-2)$ since I can append $2,0$ to any string of length $n-2$. Thus all together there are $2P(n-1)+P(n-2)$ strings that fit your criteria.
$endgroup$
add a comment |
$begingroup$
Let,
$F(n)$=the number of such strings with length $n$.
$Z(n)$=the number of such strings with length $n$ starting with $0$.
$W(n)$=the number of such strings with length $n$ starting with $1$.
$T(n)$=the number of such strings with length $n$ starting with $2$.
So, $F(n)=Z(n)+W(n)+T(n)$ ... (I)
But, we can easily notice that
$Z(n)=T(n-1)+W(n-1)$
$W(n)=T(n-1)+Z(n-1)$
$T(n)=T(n-1)+W(n-1)+Z(n-1)$
Putting them in equation (I), we get
$F(n)$
$= T(n-1)+W(n-1)+T(n-1)+Z(n-1)+T(n-1)+W(n-1)+Z(n-1)$
$= ( T(n-1)+W(n-1)+Z(n-1) ) + ( T(n-1)+W(n-1)+Z(n-1) ) + T(n-1)$
$= 2F(n-1) + T(n-1)$ [ From equation (I) ]
But $T(n-1)$ means you have a $2$ in the second place, which means that you can do anything with the rest of the places, in $F(n-2)$ ways. Therefore,
$F(n) = 2F(n-1) + F(n-2)$
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1322767%2ffind-a-recurrence-relation-for-the-number-of-ternary-strings-of-length-n-that-do%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
$$P(n-1)=P(n-2)+2P(n-3)+dots+2$$
So
$$P(n)-P(n-1)=P(n-1)+P(n-2)$$
$endgroup$
add a comment |
$begingroup$
$$P(n-1)=P(n-2)+2P(n-3)+dots+2$$
So
$$P(n)-P(n-1)=P(n-1)+P(n-2)$$
$endgroup$
add a comment |
$begingroup$
$$P(n-1)=P(n-2)+2P(n-3)+dots+2$$
So
$$P(n)-P(n-1)=P(n-1)+P(n-2)$$
$endgroup$
$$P(n-1)=P(n-2)+2P(n-3)+dots+2$$
So
$$P(n)-P(n-1)=P(n-1)+P(n-2)$$
answered Jun 12 '15 at 15:40
SBareSSBareS
3,2211226
3,2211226
add a comment |
add a comment |
$begingroup$
You can think about it like this: start with a string of length $n-1$. It's last character is $xin {0, 1, 2}$. If $x=0$ or $x=1$, then you have $2$ choices for how to finish (either ${1, 2}$ if $x=0$ or ${0, 2}$ if $x=1$). If $x=2$ then we have $3$ choices for how to finish: ${0, 1, 2}$. Let's think about what the end of strings look like. I'll let $x_{0}$ denote that the $n-1$st element is a $0$, $x_{1}$ to denote that the $n-1$st element is a $1$ and $x_{2}$ to denote that the $n-1$st element is a $2$. Strings could end in any of the following ways:
$x_0 1$
$x_0 2$
$x_1 0$
$x_1 2$
$x_2 2$
$x_2 1$
$x_2 0$
Note that if I group the first 6 of these, I have counted $2P(n-1)$ strings; this is because every one of the strings of length $n-1$ either ends in a $0$, $1$ or a $2$ and I've counted each of those occurrences twice. And, I still need to count the strings that end in $x_2 0$ (or the last two digits are $2,0$). The number of ways to end in $2,0$ is precisely $P(n-2)$ since I can append $2,0$ to any string of length $n-2$. Thus all together there are $2P(n-1)+P(n-2)$ strings that fit your criteria.
$endgroup$
add a comment |
$begingroup$
You can think about it like this: start with a string of length $n-1$. It's last character is $xin {0, 1, 2}$. If $x=0$ or $x=1$, then you have $2$ choices for how to finish (either ${1, 2}$ if $x=0$ or ${0, 2}$ if $x=1$). If $x=2$ then we have $3$ choices for how to finish: ${0, 1, 2}$. Let's think about what the end of strings look like. I'll let $x_{0}$ denote that the $n-1$st element is a $0$, $x_{1}$ to denote that the $n-1$st element is a $1$ and $x_{2}$ to denote that the $n-1$st element is a $2$. Strings could end in any of the following ways:
$x_0 1$
$x_0 2$
$x_1 0$
$x_1 2$
$x_2 2$
$x_2 1$
$x_2 0$
Note that if I group the first 6 of these, I have counted $2P(n-1)$ strings; this is because every one of the strings of length $n-1$ either ends in a $0$, $1$ or a $2$ and I've counted each of those occurrences twice. And, I still need to count the strings that end in $x_2 0$ (or the last two digits are $2,0$). The number of ways to end in $2,0$ is precisely $P(n-2)$ since I can append $2,0$ to any string of length $n-2$. Thus all together there are $2P(n-1)+P(n-2)$ strings that fit your criteria.
$endgroup$
add a comment |
$begingroup$
You can think about it like this: start with a string of length $n-1$. It's last character is $xin {0, 1, 2}$. If $x=0$ or $x=1$, then you have $2$ choices for how to finish (either ${1, 2}$ if $x=0$ or ${0, 2}$ if $x=1$). If $x=2$ then we have $3$ choices for how to finish: ${0, 1, 2}$. Let's think about what the end of strings look like. I'll let $x_{0}$ denote that the $n-1$st element is a $0$, $x_{1}$ to denote that the $n-1$st element is a $1$ and $x_{2}$ to denote that the $n-1$st element is a $2$. Strings could end in any of the following ways:
$x_0 1$
$x_0 2$
$x_1 0$
$x_1 2$
$x_2 2$
$x_2 1$
$x_2 0$
Note that if I group the first 6 of these, I have counted $2P(n-1)$ strings; this is because every one of the strings of length $n-1$ either ends in a $0$, $1$ or a $2$ and I've counted each of those occurrences twice. And, I still need to count the strings that end in $x_2 0$ (or the last two digits are $2,0$). The number of ways to end in $2,0$ is precisely $P(n-2)$ since I can append $2,0$ to any string of length $n-2$. Thus all together there are $2P(n-1)+P(n-2)$ strings that fit your criteria.
$endgroup$
You can think about it like this: start with a string of length $n-1$. It's last character is $xin {0, 1, 2}$. If $x=0$ or $x=1$, then you have $2$ choices for how to finish (either ${1, 2}$ if $x=0$ or ${0, 2}$ if $x=1$). If $x=2$ then we have $3$ choices for how to finish: ${0, 1, 2}$. Let's think about what the end of strings look like. I'll let $x_{0}$ denote that the $n-1$st element is a $0$, $x_{1}$ to denote that the $n-1$st element is a $1$ and $x_{2}$ to denote that the $n-1$st element is a $2$. Strings could end in any of the following ways:
$x_0 1$
$x_0 2$
$x_1 0$
$x_1 2$
$x_2 2$
$x_2 1$
$x_2 0$
Note that if I group the first 6 of these, I have counted $2P(n-1)$ strings; this is because every one of the strings of length $n-1$ either ends in a $0$, $1$ or a $2$ and I've counted each of those occurrences twice. And, I still need to count the strings that end in $x_2 0$ (or the last two digits are $2,0$). The number of ways to end in $2,0$ is precisely $P(n-2)$ since I can append $2,0$ to any string of length $n-2$. Thus all together there are $2P(n-1)+P(n-2)$ strings that fit your criteria.
answered Jun 12 '15 at 17:08
TravisJTravisJ
6,36831830
6,36831830
add a comment |
add a comment |
$begingroup$
Let,
$F(n)$=the number of such strings with length $n$.
$Z(n)$=the number of such strings with length $n$ starting with $0$.
$W(n)$=the number of such strings with length $n$ starting with $1$.
$T(n)$=the number of such strings with length $n$ starting with $2$.
So, $F(n)=Z(n)+W(n)+T(n)$ ... (I)
But, we can easily notice that
$Z(n)=T(n-1)+W(n-1)$
$W(n)=T(n-1)+Z(n-1)$
$T(n)=T(n-1)+W(n-1)+Z(n-1)$
Putting them in equation (I), we get
$F(n)$
$= T(n-1)+W(n-1)+T(n-1)+Z(n-1)+T(n-1)+W(n-1)+Z(n-1)$
$= ( T(n-1)+W(n-1)+Z(n-1) ) + ( T(n-1)+W(n-1)+Z(n-1) ) + T(n-1)$
$= 2F(n-1) + T(n-1)$ [ From equation (I) ]
But $T(n-1)$ means you have a $2$ in the second place, which means that you can do anything with the rest of the places, in $F(n-2)$ ways. Therefore,
$F(n) = 2F(n-1) + F(n-2)$
$endgroup$
add a comment |
$begingroup$
Let,
$F(n)$=the number of such strings with length $n$.
$Z(n)$=the number of such strings with length $n$ starting with $0$.
$W(n)$=the number of such strings with length $n$ starting with $1$.
$T(n)$=the number of such strings with length $n$ starting with $2$.
So, $F(n)=Z(n)+W(n)+T(n)$ ... (I)
But, we can easily notice that
$Z(n)=T(n-1)+W(n-1)$
$W(n)=T(n-1)+Z(n-1)$
$T(n)=T(n-1)+W(n-1)+Z(n-1)$
Putting them in equation (I), we get
$F(n)$
$= T(n-1)+W(n-1)+T(n-1)+Z(n-1)+T(n-1)+W(n-1)+Z(n-1)$
$= ( T(n-1)+W(n-1)+Z(n-1) ) + ( T(n-1)+W(n-1)+Z(n-1) ) + T(n-1)$
$= 2F(n-1) + T(n-1)$ [ From equation (I) ]
But $T(n-1)$ means you have a $2$ in the second place, which means that you can do anything with the rest of the places, in $F(n-2)$ ways. Therefore,
$F(n) = 2F(n-1) + F(n-2)$
$endgroup$
add a comment |
$begingroup$
Let,
$F(n)$=the number of such strings with length $n$.
$Z(n)$=the number of such strings with length $n$ starting with $0$.
$W(n)$=the number of such strings with length $n$ starting with $1$.
$T(n)$=the number of such strings with length $n$ starting with $2$.
So, $F(n)=Z(n)+W(n)+T(n)$ ... (I)
But, we can easily notice that
$Z(n)=T(n-1)+W(n-1)$
$W(n)=T(n-1)+Z(n-1)$
$T(n)=T(n-1)+W(n-1)+Z(n-1)$
Putting them in equation (I), we get
$F(n)$
$= T(n-1)+W(n-1)+T(n-1)+Z(n-1)+T(n-1)+W(n-1)+Z(n-1)$
$= ( T(n-1)+W(n-1)+Z(n-1) ) + ( T(n-1)+W(n-1)+Z(n-1) ) + T(n-1)$
$= 2F(n-1) + T(n-1)$ [ From equation (I) ]
But $T(n-1)$ means you have a $2$ in the second place, which means that you can do anything with the rest of the places, in $F(n-2)$ ways. Therefore,
$F(n) = 2F(n-1) + F(n-2)$
$endgroup$
Let,
$F(n)$=the number of such strings with length $n$.
$Z(n)$=the number of such strings with length $n$ starting with $0$.
$W(n)$=the number of such strings with length $n$ starting with $1$.
$T(n)$=the number of such strings with length $n$ starting with $2$.
So, $F(n)=Z(n)+W(n)+T(n)$ ... (I)
But, we can easily notice that
$Z(n)=T(n-1)+W(n-1)$
$W(n)=T(n-1)+Z(n-1)$
$T(n)=T(n-1)+W(n-1)+Z(n-1)$
Putting them in equation (I), we get
$F(n)$
$= T(n-1)+W(n-1)+T(n-1)+Z(n-1)+T(n-1)+W(n-1)+Z(n-1)$
$= ( T(n-1)+W(n-1)+Z(n-1) ) + ( T(n-1)+W(n-1)+Z(n-1) ) + T(n-1)$
$= 2F(n-1) + T(n-1)$ [ From equation (I) ]
But $T(n-1)$ means you have a $2$ in the second place, which means that you can do anything with the rest of the places, in $F(n-2)$ ways. Therefore,
$F(n) = 2F(n-1) + F(n-2)$
edited Jan 15 at 21:17
answered Nov 30 '16 at 15:58
saquib2508saquib2508
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1322767%2ffind-a-recurrence-relation-for-the-number-of-ternary-strings-of-length-n-that-do%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown