Generating all possible topologies in a full binary tree having n nodes
I want to create all possible topologies of a full binary tree which must have exactly n+1 leaf nodes and n internal nodes. I want to create it using recursion and tree must be simple binary tree not a binary search tree or BST. Kindly suggest algorithm to achieve this task. example: with 4 leaf nodes and 3 internal nodes. N N N / \ / \ /\ N N N N N N /\ /\ /\ /\ N N N N N N N N / \ /\ N N N N PS: There is a simlar thread .It will be helpful If anybody can elaborate the tree generation algorithm suggested by coproc in this thread . Thanks in advance. Here is the code for generating all