Help:=proc(): print(`BT(n), Images(T), UBT(n) `): end: #BT(n): the set of rooted binary trees with n leaves BT:=proc(n) local S,k,S1,S2,s1,s2: option remember: if n=1 then RETURN({[]}): fi: S:={}: for k from 1 to n-1 do S1:=BT(k): S2:=BT(n-k): S:= S union {seq( seq([s1,s2],s1 in S1), s2 in S2)}: od: S: end: #Images(T): Images:=proc(T) local T1,T2,t1,t2,S: if T=[] then RETURN({[]}): fi: T1:=Images(T[1]): T2:=Images(T[2]): S:={}: for t1 in T1 do for t2 in T2 do S:=S union {[t1,t2],[t2,t1]}: od: od: S: end: #UBT(n): all the unlabeled binary trees with n vertices UBT:=proc(n) local S1,S2,S3: S1:=BT(n): S2:={}: while S1<>{} do S3:=Images(S1[1]): S2:=S2 union {S3[1]}: S1:=S1 minus S3: od: S2: end: