Download the data. They contain trees (i.e. just nodes and edges, no ordering) in two different formats, encoded by a structure (-s) or by a reference (-l). The reference encoding just represents a root of the tree as
root.
and any other node with the edge to its parent as
child.parent
(one node per line in no particular order).
The structured encoding uses the recursive notation
parent(child1,child2)
The parent is always on the left, the list of children is always on the right. The whole structure is encoded on one line.
The node names cannot contain the special characters .(,)
and whitespace.
Write a script that converts the second format (-l) to the first one (-s). Report and classify any error encountered in the input file.
Note: For this homework, you will only need the -l files from the downloaded data. Consider the -s files to be just examples of the structured format.
By reference:
a. b.a c.a d.a e.c f.c
By structure:
a(b,c(e,f),d)