Design pattern for isomorphic trees
Posted
by
Peregring-lk
on Programmers
See other posts from Programmers
or by Peregring-lk
Published on 2012-12-11T13:15:30Z
Indexed on
2012/12/11
17:23 UTC
Read the original article
Hit count: 422
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.
Example:
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?
© Programmers or respective owner