search for: findbintreesord

Displaying 1 result from an estimated 1 matches for "findbintreesord".

2012 Jun 18
1
Listing all binary trees of an ordinal set
...if (len.x > 2) { y=list() for (i in 1:(len.x-1)) y[[i]] = list(g(x[1:i]),g(x[-i:-1])) return(y) } else return(x) } trim = function(x) { for (i in 1:length(x)) { if ((length(x[[i]]) == 1) && is.list(x[[i]])) x[[i]] = x[[i]][[1]] } return(x) } findBinTreesOrd=function(x) { x.lst = sort(unlist(x)) all.bin.trees = g(x.lst) trim(all.bin.trees) } returns the trees in a compact, recursively nested form that I haven't found a way to expand to the format that I desire. Any help in either writing a wrapper for that or a different approach to achieve...