Given n nodes. Find the number of different structural
binary trees that can be formed using the nodes.

Answer Posted / sayandip ghosh

The max number of binary trees that can be formed from n
nodes is given by the Catlan Number C(n).

C(n) = (2n)! / (n+1)!*n! for n>=0.

int findNoTree(int low ,int high)
{
int sum=0;
if(low<=high)
{
for(int k=low;k<=high;k++)
{
if(k==low)
sum+=findNoTree(low+1,high);
else
{
if(k==high)
sum+=findNoTree(low,high-1);
else

sum=sum+findNoTree(low,k-1)*findNoTree(k+1,high);
}
}

return sum;
}
return 1;
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

2401


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1066


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

1768


Design an implement of the inputs functions for event mode

2956


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

3843






how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

2136


how to test pierrot divisor

2253


Sir... please give some important coding questions asked by product companies..

1793


What is full form of PEPSI

1857


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2322


How to palindrom string in c language?

8822


What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

3705


3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.

3317


Cluster head selection in Wireless Sensor Network using C programming language.

3107


write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30

2219