Which data structure to use?

Hi
I am trying to parse a file with the following hierarchial structure and store the information in a tree.

nodeA
+-nodeB
++-nodeD
++-nodeE
+-nodeF
+-nodeC
++-nodeG
++-nodeH
++-nodeI
(+- is the first lvel, ++- is the second level and so on, the spaces are not showing up when I post this)
The number of levels and the number of nodes in each level in the file are not known in advance (ie) the file format can be varying. I need to store the information without losing the hierarchy as I need this information for further processing once this file is parsed and stored.

I have been looking at family trees as I am not able to think of anything closer to represent this.Any suggestions on the kind of data structures I can use to represent this?

Thanks in advance
Last edited on
perhaps you could write it with the [code] flag format to make your spaces show if so desired. Sorry that I can't help you much more than that.
1
2
3
4
5
6
7
class tree{
private:
   struct node{
      container<node*> children;
      node *parent; //if you want
   };
   node header; //or node *root if you prefer 
Which data structure to use?
store the information in a tree.

I think you answered yourself.
Topic archived. No new replies allowed.