Strategy for preserving a heap image...
(a)
S = HashTable() // "stack" (maybe have one for cons, one for symbol
// and one for vectors?)
V = HashTable() // "visited"
V2 = HashTable() // "visited twice"
for each root, insert item into S, insert item into V
while S is non-empty do
p = an item removed from S
for each x referred to be p
[note: referred to may be modified for Cons cells to
iterate down lists here]
if x is in V then
if x is not in V2 then insert x into V2
else
insert x into S and V
[each item stored in V2 is <item, number> where the number is an index]