So as the title suggests anyone has/ knows of an algorithm (in java if possible)to generate all possible binary trees given the number of leaves as in the example of the second link below?
` N N N
/ \ / \ /\
N N N N N N
/\ /\ /\ /\
N N N N N N N N
/ \ /\
N N N N
I´ve already been to this , this, this and this but I have tried to implement each and they don´t do what I´m looking for or not explained properly. The first one would be a lot of computation if I have to first generate all possible strings and then parse them to tree type (parent-children relation) and the second one does not print all trees. Because, for instance if I execute by specifying 3 internal nodes like the example above, it just prints one tree(the one on the left). I know from researching about Catalan numbers that even for a small number of nodes the number of trees grows by a lot but is a useful tool for low number of nodes.