How to dump data from a file into tree

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Scholar
    New Member
    • Aug 2008
    • 9

    How to dump data from a file into tree

    Hello friends,
    I am working on a problem where i need to dump huge amount of data from a file into a tree for analysis. The data in the file would be in specific format something like given below:

    node1 child1 child2
    child1 child3 child4
    child2 child5 child6

    Since there would be thousands of such lines i need a very optimised way to acheive it.
    The format of the file could be modified depending upon the requirements.So can you please suggest the best possible method to achieve it.Are their any specific libraries that take input data from a file and dump it into a tree? Or do i need to write the routine to achieve it.

    Regards,
    Mukesh
  • Jerry Winston
    Recognized Expert New Member
    • Jun 2008
    • 145

    #2
    I'm not sure about your data layout or I may be over simplifying the problem. Is the sample the EXACT format and content of the data in your data file or is there a more detailed root,node,leaf structure? If not, consider that each of your child# data elements carries a number(#) you can use to build your tree. A simple fn_addToTree(my Tree,myValue,ge tNumberPart(myV alue)) function might do the trick.

    fn_addToTree(my Tree TreeDataType, myValue valueDataType, numberPart int)

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Are you using C++?

      If so, consider using a map container. No point is writing tree code all over again.

      Comment

      Working...