Re: [algogeeks] number of BST's

2010-07-31 Thread Apoorve Mohan
is n not the number of nodes? On Fri, Jul 30, 2010 at 11:58 AM, Pramod Negi wrote: > Follow up on Catalon Nubmer... > > > > On Fri, Jul 30, 2010 at 10:44 AM, Amit Jaspal wrote: > >> n is clearly a number lets say 3 then BST's with 1,2,3 values as key are >> to be calculated >> >> >> On Fri, Jul

Re: [algogeeks] number of BST's

2010-07-31 Thread Ram Kumar
The question is to find the no of structures possible for a BST which is directly given bycomputing the catalan number for n(no of nodes) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegro

Re: [algogeeks] number of BST's

2010-07-31 Thread ankur bhardwaj
int num_of_BST(int n) { int sum=0; int left,right,root; if(n<=1) return 1; else { for(root=1;root<=n;root++) { left=num_of_BST(root-1); right=num_of_BST(n-root); sum+=left*right; } } return sum; } On Thu, Jul 29, 2010 at 9:56 PM, amit wrote: > Given the numbers from 1 to n, write an algorithm to

Re: [algogeeks] number of BST's

2010-07-30 Thread Ram Kumar
@abaove : sorry the formula stated prev is wrong. is (2n Cn)/(n+1) or (2n!)/(n+1)!*n! both being the same. refer catalan numbers -- Ramkumar.G -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@go

Re: [algogeeks] number of BST's

2010-07-30 Thread Ram Kumar
@sharad BST is not unique, anyway the formula is correct -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@go

Re: [algogeeks] number of BST's

2010-07-29 Thread Pramod Negi
Follow up on Catalon Nubmer... On Fri, Jul 30, 2010 at 10:44 AM, Amit Jaspal wrote: > n is clearly a number lets say 3 then BST's with 1,2,3 values as key are to > be calculated > > > On Fri, Jul 30, 2010 at 9:08 AM, Apoorve Mohan wrote: > >> @AMIT: what does "n" represents? >> >> >> On Fri, Jul

Re: [algogeeks] number of BST's

2010-07-29 Thread Amit Jaspal
n is clearly a number lets say 3 then BST's with 1,2,3 values as key are to be calculated On Fri, Jul 30, 2010 at 9:08 AM, Apoorve Mohan wrote: > @AMIT: what does "n" represents? > > > On Fri, Jul 30, 2010 at 5:46 AM, sharad kumar wrote: > >> @amit is it BST or binary tree??cos BST is unique rite

Re: [algogeeks] number of BST's

2010-07-29 Thread Apoorve Mohan
@AMIT: what does "n" represents? On Fri, Jul 30, 2010 at 5:46 AM, sharad kumar wrote: > @amit is it BST or binary tree??cos BST is unique rite???binary tree meas > use catalan numbers 2nCn/(n+1)! > > > > On Thu, Jul 29, 2010 at 9:56 PM, amit wrote: > >> Given the numbers from 1 to n, write an al

Re: [algogeeks] number of BST's

2010-07-29 Thread sharad kumar
@amit is it BST or binary tree??cos BST is unique rite???binary tree meas use catalan numbers 2nCn/(n+1)! On Thu, Jul 29, 2010 at 9:56 PM, amit wrote: > Given the numbers from 1 to n, write an algorithm to find how many > distinct binary search trees can be formed.. eg n=4, no of distinct > bs

[algogeeks] number of BST's

2010-07-29 Thread amit
Given the numbers from 1 to n, write an algorithm to find how many distinct binary search trees can be formed.. eg n=4, no of distinct bst's are 14. ?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algog