Bert Gunter <gunter.ber...@gene.com> writes:

> Lists are (isomorphic to) trees with (possibly) labelled nodes. A
> completely general solution in which two trees have possibly different
> topologies and different labels would therefore involve identifying
> the paths to leaves on each tree, e.g. via depth first search using
> recursion, and unioning leaves with the same paths (which could be
> quickly found in R via match() on the paths). This is a standard
> exercise in a data structures course.
>
> Considerable simplification could be effected if tree topologies
> and/or labels are identical or have other restrictions on them.
> However, you have not made it clear in your post whether this is the
> case (it is in your example).
>

Thanks so much to all of you for your very helpful suggestions, that
helped me solve my problem.

The tree topologies are indeed identical, so the suggested solutions did
work, but just for me to learn: Can somebody point me to how a general
solution mentioned by Bert would look like?

Cheers,

Georg

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to