Hi. This is a problem of the infamous LCA in binary trees..! I heard that this can be easily implemented in perl using a CPAN module called "bioperl". I have never used it ..so have no idea. if any one knows , or used it before..if they can write a small program for the below program..it would be great.
Thanks -------------------------------------------------------------- Problem:
Write a class for a "Doubly-Linked" Tree; child nodes have links to their parents and vice versa (whatever the proper term is for such a tree). This tree can be a binary tree, for simplicity, and should only have one root node. Using the above class, write a subroutine, common_parent(node1, node2), which return the first parent node that the two nodes have in common.