int countTreesRec(int numKeys) {
        if (numKeys <=1) {
            return(1);
        }
        else {
            int sum = 0;
            int left, right, root;
            for (root=1; root<=numKeys; root++) {
                left = countTreesRec(root - 1);
                right = countTreesRec(numKeys - root);
                sum += left*right;
            }
            return(sum);
        }
    }
http://www.geeksforgeeks.org/program-nth-catalan-number/
Count number of binary search tree created for array of size n
src/com/interview/dynamic/CountNumberOfTreesInBST.java