Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int TotalBSTPossible(int n){
- if(n<=1)
- return 1;
- int sum=0;
- for(int root=1;root<=n;root++){
- int left=TotalBSTPossible(root-1);
- int right=TotalBSTPossible(n-root);
- sum+=left*right;
- }
- return sum;
- }
- int main(){
- int n=4;
- cout<<TotalBSTPossible(n);
- return 0;
- }
Add Comment
Please, Sign In to add comment