Encoding Tree Input

Reading in and reconstructing the tree is also recursive:

1.
Read a character byte.
2.
If the character is ``.'' (period), then we have a leaf:
(a)
Read the next byte, and create a new tree with that value in its node.
(b)
Return the new tree.
3.
Otherwise, the character must be a left parentheses, indicating we have two subtrees:
(a)
Recursively read in the left subtree.
(b)
Read in and skip the closing right parentheses and the next left parentheses.
(c)
Recursively read in the right subtree.
(d)
Read in and skip the closing right parentheses.
(e)
Create a new tree combining the left and right subtrees, and return it.


Charles Stewart
10/2/1998