4. A=(b,c,d) LIST=(A,a,(A,A))
b we might expectA=(c,d) ways to representthe same basic within
As
, ,These are many variations on List structures theme
a computer memory.
there
are usually
according to which binary trees are used to represent general forests of trees:
8ay, is used to point to the next element of a List, and another
LIST 3 -> b
one field
‘
field DLINI may be used to point to the first element of a sub-List. By a natural
extension of the memory representation described in Section 2.3.2, we would
represent the List (5) as follows:
b (atom) c e
-
-
g
(6)
-
-
7. Memory &raight linkage Circular linkagc Doublc linkagc
……
location
……
INFO DLINK RLINK INFO DLINK
L…
m
RLINK INFO
h
[
o
om
RLINK
…… om
(t
b m ’6V W
b
o
mw
c
e A
m
c
t
O%
Om m
FU
( mm
{
h
” O mm
O
m
m (8)
-f -f -f
m m I m l m O%
g A g l % g l % om
-d m -d Lm a -d h m
J l % m
A o% { 0%
m A ka m h 1m m
- ’m h I
m h mm om mm
h
( m I %
J A 0m
w m { m l %
3 J
Here “LLINK" is used for a pointe1' to the left in a doubly linked 1'epresentation.
8. MIX
a) 1
S T REF RLINK
b)2
S T LLINK RLINK
INFO
s( ) :
t( ) : t=0 ,t=1
t>1
REF :
L,RLINK :
INFO : .( ,
, ..)
35. B TOP,Q
After Aftcl'
ALINK BLINK
E4. E5.
El. E2. Down Down E6. Up
Tnitinlìzc Mnrk ALINK I Mnrkcd BLINK I :hrked
already alrcady
Fig. 38. Flowchart f0 1' AIgorithm E.
E5. [Down BLINK.] Set Q • BLINK(P). If Q A and MARK(Q) = 0 , set
BLINK(P) • T, T • P, P • Q, and go to E2.
E6. [Up.] (This step undoes the link switching made in step E4 or E5; the
setting of ATOM (T) tells ALINK(T) or BLINK (T) is to be restored.)