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
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
#include
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 ??
Design an implement of the inputs functions for event mode
Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?
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.
how to test pierrot divisor
Sir... please give some important coding questions asked by product companies..
What is full form of PEPSI
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
How to palindrom string in c language?
What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?
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.
Cluster head selection in Wireless Sensor Network using C programming language.
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