Exercise 5.20. Draw the box-and-pointer representation and the memory-vector representation (as in figure 5.14) of the list structure produced by
(define x (cons 1 2))
(define y (list x x))
with the free pointer initially p1. What is the final value of free ? What pointers represent the values of x and y ?
y--> +---+---+
| | +-------+
+-+-+---+ |
| |
|+------------+
||
vv
+---+---+
x--> | | |
+-+-+-+-+
| |
v v
+---+ +---+
| 1 | | 2 |
+-+-+ +---+
index 0 1 2 3 4 5 6
the-cars n1 p1
the-cdrs n2 p1
(cons 1 2) 之后,free 变为 p2。 (list x x) 之后,free 变为 p3。
p1 代表 x,p2 代表 y。