Help:=proc(): print(` DT(T,a,b,i,eps), Trees(k) `): end: with(plots): #plots a binary tree T with vertex at y=i and using a<=x<=b #such that the left child gets the left territory for i+1 #and the right child ... DT:=proc(T,a,b,i,eps) local v,pic,pic1,pic2: v:={[(a+b)/2,i]}: pic:=plot(v,style=point,axes=none): if T={} then RETURN(NULL): fi: pic1:=DT(T[1],a,(a+b)/2-eps,i+1,eps): pic2:=DT(T[2],(a+b)/2+eps,b,i+1,eps): pic:=pic,pic1,pic2: if T[1]<>{} then pic:=pic,plot([v[1], [(a+(a+b)/2-eps)/2 ,i+1] ] ): fi: if T[2]<>{} then pic:=pic,plot([v[1], [((a+b)/2+eps+b)/2 ,i+1] ] ): fi: RETURN(pic): end: #the set of all binary trees of depth <=k Trees:=proc(k) local S,t1,t2: if k=0 then RETURN({ {} }): fi: S:=Trees(k-1): {seq(seq( [ t1,t2 ], t1 in S),t2 in S),{}}: end: