hoffmann has asked for the wisdom of the Perl Monks concerning the following question:
I have the following problem:
Suppose I have a tree of data as follows (Labels represent the branches of the tree, Nodes represent data "leaves" contained in the branches):I want to move every "label" or "branch" of the tree that contains only one "node" or "leaf" into the highest level of the tree and delete that branch. I basically want to remove the branches that contain one leaf and move the data from that leaf into the highest level of the tree. So for the example I have, I would like it to become the following:Label1 Node1 Node2 Label2 Node3 Label3 Node4 Node5 Label4 Node6.
What is the best way to code such a problem, and would any one language be suitable for this task? The data I have is in an excel file so I suppose I could do it in there but I'm looking for a more elegant way to do it, preferably in Perl.Label1 Node1 Node2 Node3 Node6 Label3 Node4 Node5.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moving data in a tree
by shoness (Friar) on Jul 21, 2008 at 22:08 UTC | |
|
Re: Moving data in a tree
by moritz (Cardinal) on Jul 21, 2008 at 20:43 UTC | |
by wade (Pilgrim) on Jul 21, 2008 at 20:56 UTC | |
by hoffmann (Novice) on Jul 21, 2008 at 21:10 UTC | |
by wade (Pilgrim) on Jul 21, 2008 at 21:36 UTC | |
by ysth (Canon) on Jul 22, 2008 at 06:45 UTC | |
|
Re: Moving data in a tree
by ikegami (Patriarch) on Jul 21, 2008 at 22:40 UTC | |
by hoffmann (Novice) on Jul 21, 2008 at 23:37 UTC | |
by wade (Pilgrim) on Jul 22, 2008 at 00:08 UTC | |
|
Re: Moving data in a tree
by GrandFather (Saint) on Jul 22, 2008 at 05:05 UTC |