views:

302

answers:

2

I have a problem about Linked Lists. I already know how to create structures and linked list. But now I have to create arbitrary number of linked list which are also be kept in another structure. Which means :

struct list{int x, struct list *next; };
struct parent{int x, struct list  *head, struct parent *next;}   

And after lists are created when i enter this input for example "123134" linked list should look like :

1 -> 2 -> 3 -> 4

And for example 1 will contain 2->3 list inside of it, 3 will contain 1->4 list inside of it.

I need a starting point and a spark from you. So how can i do this?

A: 

The thing here is I want to say again, there will be creation of a lot of linked list how that will be handled? and storing in another structure is also problematic.

LuckySlevin
A: 

Draw your list diagram, which often helps.

Start
 |
list1 -> node1 -> node2
 |
list2 -> node_a -> node_b -> node_c
 |
list3 {empty}
 |
list4 -> node_1A

Given a diagram like the above, the lists have two links, one to their own nodes, another to another list. Some objects may need more than one link field.

In your case, draw a diagram. Try inserting a new item. Write down the steps you take (and draw).

If you supply more details in your question, more people will assist.

For an example of a list with nodes containing many lists, see a BTree data structure. Each node contains an array of links to other "subtrees".

Thomas Matthews
thanks for the comment. Actually i want to put some code to get people's ideas about this issue. This is why i'm waiting :)
LuckySlevin