由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - How many different binary trees are possible with n nodes ?
相关主题
amazon一道面试题amazon first phone interview, rejected
问道题,binary tree里有一个有indegree 2判断 bst 疑问
Lowest common ancestor of two nodes of Binary Treenon recursive binary tree traversal in O(n) time and O(1) space
How many full binary trees?一道大公司诡异的complete binary tree max sum of 2 nodes 题
求教一道老题问个binary tree node path的概念问题
这个Binary Tree的题来看看问个amazon面试题
讨论个Binary search tree的题目full or complete binary tree的问题
请问一个简单的面试题generate all distinct full binary trees with n leaves
相关话题的讨论汇总
话题: nodes话题: trees话题: binary话题: int
进入JobHunting版参与讨论
1 (共1页)
m********t
发帖数: 94
1
网上一道题 答案是2^n-n
对于1 2 3都是对的
ms答案没有错
不过知道答案还是不知道怎么算。。。
大家有思路么?
f*********5
发帖数: 576
2
for 2 node,there are 4 possibilities
a a b b
b b a a

【在 m********t 的大作中提到】
: 网上一道题 答案是2^n-n
: 对于1 2 3都是对的
: ms答案没有错
: 不过知道答案还是不知道怎么算。。。
: 大家有思路么?

t*******7
发帖数: 108
3
catalan number
f*********5
发帖数: 576
4
if only considering the shape.
for example, consider below two as the same
a b
b a
int f(int n)
{
if (n<0) return 0;
if(n==1||n==0) return 1;
int sum=0;
for(int i=0;i {
sum+=f(i)*f(n-1-i);
}
return sum;
}

【在 m********t 的大作中提到】
: 网上一道题 答案是2^n-n
: 对于1 2 3都是对的
: ms答案没有错
: 不过知道答案还是不知道怎么算。。。
: 大家有思路么?

m********t
发帖数: 94
5
bingo
then we can use induction to proof that though not an easy one

【在 f*********5 的大作中提到】
: if only considering the shape.
: for example, consider below two as the same
: a b
: b a
: int f(int n)
: {
: if (n<0) return 0;
: if(n==1||n==0) return 1;
: int sum=0;
: for(int i=0;i
1 (共1页)
进入JobHunting版参与讨论
相关主题
generate all distinct full binary trees with n leaves求教一道老题
弱问怎么判断两个binary tree相同?这个Binary Tree的题来看看
recover binary search tree 常数空间讨论个Binary search tree的题目
binary tree, sum of 2 nodes == given number请问一个简单的面试题
amazon一道面试题amazon first phone interview, rejected
问道题,binary tree里有一个有indegree 2判断 bst 疑问
Lowest common ancestor of two nodes of Binary Treenon recursive binary tree traversal in O(n) time and O(1) space
How many full binary trees?一道大公司诡异的complete binary tree max sum of 2 nodes 题
相关话题的讨论汇总
话题: nodes话题: trees话题: binary话题: int