What is the number of distinct full binary trees with n nodes?
$begingroup$
I'm trying to find a recurrence relation for how many full binary trees there are with n nodes. However, once I get to n = 11, it's there's a lot of trees to keep track of. I've written out the cases for $$n in [1,9] $$ where n is odd but I can't figure out the pattern.
At n=1, I have 1.
n = 3, I have 1
n = 5 : 2 /// n = 7 : 5 /// n = 9 : 14
Basically I took the leaves from the previous nth tree I created and added 2 nodes to each leaf for all possible full binary trees then got rid of duplicates. I.e for n = 7, I took leaves from n = 5, which is 3 and added 2 nodes to each leaf from all the fbts possible when n = 5 (which is 2) and so I end up with 6 fbts, but there's 1 duplicate so I subtract 1 to end up with 5 distinct fbts.
Any help on figuring out the pattern or atleast how many distinct fbts with n nodes?
recurrence-relations trees
$endgroup$
add a comment |
$begingroup$
I'm trying to find a recurrence relation for how many full binary trees there are with n nodes. However, once I get to n = 11, it's there's a lot of trees to keep track of. I've written out the cases for $$n in [1,9] $$ where n is odd but I can't figure out the pattern.
At n=1, I have 1.
n = 3, I have 1
n = 5 : 2 /// n = 7 : 5 /// n = 9 : 14
Basically I took the leaves from the previous nth tree I created and added 2 nodes to each leaf for all possible full binary trees then got rid of duplicates. I.e for n = 7, I took leaves from n = 5, which is 3 and added 2 nodes to each leaf from all the fbts possible when n = 5 (which is 2) and so I end up with 6 fbts, but there's 1 duplicate so I subtract 1 to end up with 5 distinct fbts.
Any help on figuring out the pattern or atleast how many distinct fbts with n nodes?
recurrence-relations trees
$endgroup$
$begingroup$
You need to define "distinct" carefully. This link may be of interest: durangobill.com/BinTrees.html
$endgroup$
– Alexis Olson
Nov 1 '16 at 18:38
$begingroup$
There is a very interesting video about Catalan numbers and how it is related to binary trees and many other things: youtube.com/watch?v=etzcN6g-vNY It is in French sorry, but if you select French subtitles + auto translation it gives fairly good English. (you can skip directly to 6:00)
$endgroup$
– zwim
Dec 23 '18 at 2:27
$begingroup$
Relevant post from CS-SE.
$endgroup$
– JavaMan
Dec 23 '18 at 3:49
add a comment |
$begingroup$
I'm trying to find a recurrence relation for how many full binary trees there are with n nodes. However, once I get to n = 11, it's there's a lot of trees to keep track of. I've written out the cases for $$n in [1,9] $$ where n is odd but I can't figure out the pattern.
At n=1, I have 1.
n = 3, I have 1
n = 5 : 2 /// n = 7 : 5 /// n = 9 : 14
Basically I took the leaves from the previous nth tree I created and added 2 nodes to each leaf for all possible full binary trees then got rid of duplicates. I.e for n = 7, I took leaves from n = 5, which is 3 and added 2 nodes to each leaf from all the fbts possible when n = 5 (which is 2) and so I end up with 6 fbts, but there's 1 duplicate so I subtract 1 to end up with 5 distinct fbts.
Any help on figuring out the pattern or atleast how many distinct fbts with n nodes?
recurrence-relations trees
$endgroup$
I'm trying to find a recurrence relation for how many full binary trees there are with n nodes. However, once I get to n = 11, it's there's a lot of trees to keep track of. I've written out the cases for $$n in [1,9] $$ where n is odd but I can't figure out the pattern.
At n=1, I have 1.
n = 3, I have 1
n = 5 : 2 /// n = 7 : 5 /// n = 9 : 14
Basically I took the leaves from the previous nth tree I created and added 2 nodes to each leaf for all possible full binary trees then got rid of duplicates. I.e for n = 7, I took leaves from n = 5, which is 3 and added 2 nodes to each leaf from all the fbts possible when n = 5 (which is 2) and so I end up with 6 fbts, but there's 1 duplicate so I subtract 1 to end up with 5 distinct fbts.
Any help on figuring out the pattern or atleast how many distinct fbts with n nodes?
recurrence-relations trees
recurrence-relations trees
asked Nov 1 '16 at 18:15
ChubblesChubbles
8619
8619
$begingroup$
You need to define "distinct" carefully. This link may be of interest: durangobill.com/BinTrees.html
$endgroup$
– Alexis Olson
Nov 1 '16 at 18:38
$begingroup$
There is a very interesting video about Catalan numbers and how it is related to binary trees and many other things: youtube.com/watch?v=etzcN6g-vNY It is in French sorry, but if you select French subtitles + auto translation it gives fairly good English. (you can skip directly to 6:00)
$endgroup$
– zwim
Dec 23 '18 at 2:27
$begingroup$
Relevant post from CS-SE.
$endgroup$
– JavaMan
Dec 23 '18 at 3:49
add a comment |
$begingroup$
You need to define "distinct" carefully. This link may be of interest: durangobill.com/BinTrees.html
$endgroup$
– Alexis Olson
Nov 1 '16 at 18:38
$begingroup$
There is a very interesting video about Catalan numbers and how it is related to binary trees and many other things: youtube.com/watch?v=etzcN6g-vNY It is in French sorry, but if you select French subtitles + auto translation it gives fairly good English. (you can skip directly to 6:00)
$endgroup$
– zwim
Dec 23 '18 at 2:27
$begingroup$
Relevant post from CS-SE.
$endgroup$
– JavaMan
Dec 23 '18 at 3:49
$begingroup$
You need to define "distinct" carefully. This link may be of interest: durangobill.com/BinTrees.html
$endgroup$
– Alexis Olson
Nov 1 '16 at 18:38
$begingroup$
You need to define "distinct" carefully. This link may be of interest: durangobill.com/BinTrees.html
$endgroup$
– Alexis Olson
Nov 1 '16 at 18:38
$begingroup$
There is a very interesting video about Catalan numbers and how it is related to binary trees and many other things: youtube.com/watch?v=etzcN6g-vNY It is in French sorry, but if you select French subtitles + auto translation it gives fairly good English. (you can skip directly to 6:00)
$endgroup$
– zwim
Dec 23 '18 at 2:27
$begingroup$
There is a very interesting video about Catalan numbers and how it is related to binary trees and many other things: youtube.com/watch?v=etzcN6g-vNY It is in French sorry, but if you select French subtitles + auto translation it gives fairly good English. (you can skip directly to 6:00)
$endgroup$
– zwim
Dec 23 '18 at 2:27
$begingroup$
Relevant post from CS-SE.
$endgroup$
– JavaMan
Dec 23 '18 at 3:49
$begingroup$
Relevant post from CS-SE.
$endgroup$
– JavaMan
Dec 23 '18 at 3:49
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
See: Catalan Numbers
You can use the number $C_n$ to describe the number of binary trees with $n+1$ leaf nodes, that is, $2n + 1$ nodes total.
EDIT: Here's the full reasoning.
We have $C_0 = 1$, and suppose we have $C_0, ldots, C_n$, the number of full binary trees with up to $n + 1$ leaf nodes, and we want $C_{n+1}$. Given a root node, we just need $k$ leaf nodes on one side, and $n + 1 - k$ leaf nodes on the other, for all values of $k$ from $1$ to $n$. Since there's $C_k$ ways of choosing trees for one side, and $C_{n+1-k}$ on the other, there's a total of $C_k cdot C_{n -k}$ trees for a given $k$.
Solve for this recurrence:
$$ C_0 = 1, qquad C_{n+1} = sum_{k=0}^{n}C_kC_{n-k}$$
The solution is the Catalan Numbers $C_n = frac{(2n)!}{(n+1)!n!}$.
$endgroup$
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
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%2f1994887%2fwhat-is-the-number-of-distinct-full-binary-trees-with-n-nodes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
See: Catalan Numbers
You can use the number $C_n$ to describe the number of binary trees with $n+1$ leaf nodes, that is, $2n + 1$ nodes total.
EDIT: Here's the full reasoning.
We have $C_0 = 1$, and suppose we have $C_0, ldots, C_n$, the number of full binary trees with up to $n + 1$ leaf nodes, and we want $C_{n+1}$. Given a root node, we just need $k$ leaf nodes on one side, and $n + 1 - k$ leaf nodes on the other, for all values of $k$ from $1$ to $n$. Since there's $C_k$ ways of choosing trees for one side, and $C_{n+1-k}$ on the other, there's a total of $C_k cdot C_{n -k}$ trees for a given $k$.
Solve for this recurrence:
$$ C_0 = 1, qquad C_{n+1} = sum_{k=0}^{n}C_kC_{n-k}$$
The solution is the Catalan Numbers $C_n = frac{(2n)!}{(n+1)!n!}$.
$endgroup$
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
add a comment |
$begingroup$
See: Catalan Numbers
You can use the number $C_n$ to describe the number of binary trees with $n+1$ leaf nodes, that is, $2n + 1$ nodes total.
EDIT: Here's the full reasoning.
We have $C_0 = 1$, and suppose we have $C_0, ldots, C_n$, the number of full binary trees with up to $n + 1$ leaf nodes, and we want $C_{n+1}$. Given a root node, we just need $k$ leaf nodes on one side, and $n + 1 - k$ leaf nodes on the other, for all values of $k$ from $1$ to $n$. Since there's $C_k$ ways of choosing trees for one side, and $C_{n+1-k}$ on the other, there's a total of $C_k cdot C_{n -k}$ trees for a given $k$.
Solve for this recurrence:
$$ C_0 = 1, qquad C_{n+1} = sum_{k=0}^{n}C_kC_{n-k}$$
The solution is the Catalan Numbers $C_n = frac{(2n)!}{(n+1)!n!}$.
$endgroup$
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
add a comment |
$begingroup$
See: Catalan Numbers
You can use the number $C_n$ to describe the number of binary trees with $n+1$ leaf nodes, that is, $2n + 1$ nodes total.
EDIT: Here's the full reasoning.
We have $C_0 = 1$, and suppose we have $C_0, ldots, C_n$, the number of full binary trees with up to $n + 1$ leaf nodes, and we want $C_{n+1}$. Given a root node, we just need $k$ leaf nodes on one side, and $n + 1 - k$ leaf nodes on the other, for all values of $k$ from $1$ to $n$. Since there's $C_k$ ways of choosing trees for one side, and $C_{n+1-k}$ on the other, there's a total of $C_k cdot C_{n -k}$ trees for a given $k$.
Solve for this recurrence:
$$ C_0 = 1, qquad C_{n+1} = sum_{k=0}^{n}C_kC_{n-k}$$
The solution is the Catalan Numbers $C_n = frac{(2n)!}{(n+1)!n!}$.
$endgroup$
See: Catalan Numbers
You can use the number $C_n$ to describe the number of binary trees with $n+1$ leaf nodes, that is, $2n + 1$ nodes total.
EDIT: Here's the full reasoning.
We have $C_0 = 1$, and suppose we have $C_0, ldots, C_n$, the number of full binary trees with up to $n + 1$ leaf nodes, and we want $C_{n+1}$. Given a root node, we just need $k$ leaf nodes on one side, and $n + 1 - k$ leaf nodes on the other, for all values of $k$ from $1$ to $n$. Since there's $C_k$ ways of choosing trees for one side, and $C_{n+1-k}$ on the other, there's a total of $C_k cdot C_{n -k}$ trees for a given $k$.
Solve for this recurrence:
$$ C_0 = 1, qquad C_{n+1} = sum_{k=0}^{n}C_kC_{n-k}$$
The solution is the Catalan Numbers $C_n = frac{(2n)!}{(n+1)!n!}$.
edited Nov 1 '16 at 18:50
answered Nov 1 '16 at 18:39
Larry B.Larry B.
2,799828
2,799828
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
add a comment |
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Are you not double counting some cases?
$endgroup$
– gen
Oct 11 '17 at 13:03
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
$begingroup$
Maybe it's worth adding a note about this to your answer?
$endgroup$
– gen
Oct 11 '17 at 19:18
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%2f1994887%2fwhat-is-the-number-of-distinct-full-binary-trees-with-n-nodes%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
$begingroup$
You need to define "distinct" carefully. This link may be of interest: durangobill.com/BinTrees.html
$endgroup$
– Alexis Olson
Nov 1 '16 at 18:38
$begingroup$
There is a very interesting video about Catalan numbers and how it is related to binary trees and many other things: youtube.com/watch?v=etzcN6g-vNY It is in French sorry, but if you select French subtitles + auto translation it gives fairly good English. (you can skip directly to 6:00)
$endgroup$
– zwim
Dec 23 '18 at 2:27
$begingroup$
Relevant post from CS-SE.
$endgroup$
– JavaMan
Dec 23 '18 at 3:49