0

using python I want to create a multi-linked list that each node on the main body that can have two pointers. one to the next node on the main body and one to a branch-linked list.

my input is a text file that has the main body elements at the start of each line at its branches at that line with a space in between.

example:

10 15 58

13 18 25 20

14

12 55

now I want a linked list that has 10->13->14->12 as its main body and 10 for example has 10->15->58 as its branch linked list.

moein2k
  • 1
  • 1
  • Welcome to SO - Please take the [tour] and read [ask] to improve, [edit] and format your questions. Thanks – HedgeHog Dec 01 '21 at 16:46
  • It seems that you are looking for a tree. See https://stackoverflow.com/questions/2358045/how-can-i-implement-a-tree-in-python – PM 77-1 Dec 01 '21 at 16:48
  • *"I want to create a multi-linked list"*: how is it going? Did you write any code? If so, what is the problem with it? If not, then what is the question? – trincot Dec 01 '21 at 18:09
  • what did you try? Where is your code? Show FULL error message in question (not in comments) as text (not image) – furas Dec 01 '21 at 19:54
  • You can use list of lists in python, using the `append()` of list. So, you could have [ [10,15,58], [13,18,25,20], [14], [ 12,55] ] , then you can access it as listOflists[2][1], to get the first element of your 2nd list - i.e 13 – Anand Sowmithiran Dec 05 '21 at 13:48
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 06 '21 at 14:39

0 Answers0