+ 2

How to create a general tree based of the data inside a doubly linked list?

Hello, im really in a struggle to get this task done and i will be very thankful if someone could give me a hint on this matter. Basically, i have a doubly linked list declared like this typedef struct node{ int id, idparent, nr_addr;//nr_addr is number of addresses char **addr; struct node *prev; struct node *next; } typedef struct list { int n; struct node *head; struct node *tail; } I read all this data from a file inside this list. Then using the data inside this list i have to construct an n-ary tree which is defined like this typedef struct kid { struct tnode* data; struct kid* next; struct kid*prev; } typedef struct tnode { int id, idparent, nr_addr; char **addr; struct tnode* parent; struct kid* kids; } All the nodes can have 0 to many kids. Kids of each node are stored in a doubly linked list. Knowing that the root of the tree has id 0 and id parent -1 how can i build this tree with all those kid - parent links? Any hint would be a great help.

20th Apr 2019, 12:14 PM
Emanuel Terteș
Emanuel Terteș - avatar
1 Resposta
0
Cолвед
6th May 2019, 12:46 PM
Emanuel Terteș
Emanuel Terteș - avatar