I know total number of distinct BST's possible with N distinct nodes are given by Catalan formula . Which is described in this question at SO.
But how can we use it to find all the BSTs less then or equal to n nodes(N distinct nodes)?
for e.g.
For N=3
Possible numbers of BST's are 14.
9 Shown in Picture below for less than 3.
5 for N=3 which can be obtained from Catalan formula.
What is the approach to solve it? I need only algorithmic explanation.