Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 21st, 2008, 3:32 PM   #1
hoffmann
Newbie
 
Join Date: Jul 2008
Posts: 2
Rep Power: 0 hoffmann is on a distinguished road
How can I code this?

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):

Label1
Node1
Node2
Label2
Node3
Label3
Node4
Node5
Label4
Node6

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
Node3
Node6
Label3
Node4
Node5

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 Python/Perl/Java/MATLAB. Thanks!
hoffmann is offline   Reply With Quote
Old Jul 21st, 2008, 6:04 PM   #2
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0 King is an unknown quantity at this point
Re: How can I code this?

Please see the forums rules, specifically under the "Keep It Organized" section.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorporating javascript code into java application csrocker101 Java 1 Feb 11th, 2008 6:36 AM
Viewing VB's Automated code john Wesley Visual Basic .NET 3 Jun 8th, 2006 5:37 AM
FTP and return code fetching Serinth C 2 May 28th, 2006 11:05 PM
Code Restructure, Finally! OpenLoop Show Off Your Open Source Projects 13 May 15th, 2006 4:56 PM
String to Morse Code - Copying from string to string Xenon C 29 Nov 10th, 2005 2:30 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:54 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC