I want to create a data structure to work with isomorphic tree. I don't search for a "algorithms" or methods to check if two or more trees are isomorphic each other. Just to create various trees with the same structure.


  2 - - - - - - - 'a' - - - - - - - 3.5 
 / \              / \               / \
3   3           'f' 'y'           1.0 3.1
   / \              / \               / \
  4   7           'e' 'f'           2.3 7.7

The first "layer" or tree is the "natural tree" (a tree with natural numbers), the second layer is the "character tree" and the third one is the "float tree".

The data structure has a method or iterator to traverse the tree and to make diferent operations with its values. These operations could change the value of nodes, but never its structure (first I create the structure and then I configure the tree with its diferent layers). In case of that I add a new node, this would be applied to each layer.

Which known design pattern fits with this description or is related with it?

  • Are you forced into this implementation, or can you consider other options to accomplish the same end effect? I.e. can you not just create a Node object to contain the "isomorphic"-ally associated datapoints and store these nodes in one tree? Commented Dec 11, 2012 at 18:47

1 Answer 1


If your trees are isomorphic on principle, there is no point at all in actually maintaining three parallel trees - that's just a waste of pointers and processor cycles. instead you should define a composite type that holds what ever items you want to maintain in parallel, and build one tree containing such composite nodes. Remember, how you access or present your data to other modules or users can be entirely independent from the actual data structure.

  • Answer accepted almost 8 years later... better late than ever xD
    – ABu
    Commented Sep 9, 2020 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.