We explore our tree representation convention with further exercises. In particular, we wish to have you be able to convert a figure to the Python representation, and vice versa.
We begin by asking you to provide the Python representation for the following two trees:
Next, we ask you to draw such a figure of the tree represented by the following Python expressions. (We start by helping out with whitespace and advance to expressions without such visual clues.)
('A', ('B',(),()), ('C', ('D', ('E',(),()), ('F',(),()) ), ('G',(),()) ) )
('A', ('B', ('C',(),()), ('D',(),()) ), ('E', ('F',(),()), ('G', ('H',(),()), ('I',(),()) ) ) )
('A',('B',(),()),('C',('D',(),()),('E',('F',(),()),('G',(),()))))
('A',('B',('C',(),()),('D',('E',(),()),('F',(),()))),('G', (), ()))
('A',('B',('C',(),()),('D',('E',('F',(),()),('G',(),())),('H',(),()))),('I',(),()))