From SICP
Exercise 2.24: Suppose we evaluate the expression (list 1 (list 2 (list 3 4))). Give the result printed by the interpreter, the corresponding box-and-pointer structure, and the interpretation of this as a tree (as in Figure 2.6).
The problem is my eyes are destroyed, therefore I can see neither the box and pointer diagram nor Figure 2.6. So now I only have a guess on what this list should look like as a tree based on:
Another way to think of sequences whose elements are sequences is as trees. The elements of the sequence are the branches of the tree, and elements that are themselves sequences are subtrees.
Please check my tree interpretation. This is just my imagination. I'm pretty confident this is correct, but have no way of confirming it because all of the answers to the exercise I found are pictures and my screen reader can't read them.
(list 1 (list 2 (list 3 4))) - I think this is the tree itself, or the rootnode. This tree has two branches or children.
The first branch (1) is a leaf node, so we are done at this side of the tree.
The second branch (list 2 (list 3 4) is another tree.
Now we focus on the subtree (list 2 (list 3 4). It has two children/branches.
The first branch is a leafnode (2), so we're done here.
The second branch is another tree (list 3 4).
Now we focus on the subtree (list 3 4). It has two children branches.
They are both leafnodes, so we're done.
Is this correct? Did I interpret the tree right?
Your interpretation is correct. The result printed by the interpreter is (1 (2 (3 4)))
, that is the tree that you have described.