%%off % Exercise 2.3.1-20 % Author M. Ruckert %%% P IS $0 Visit IS $1 return IS $2 S IS $3 t IS $4 %%% Left IS 0 Right IS 8 Info IS 16 %%on Inorder BZ P,1F \hfil$1$& \ul{\sl T1. Initialize.} Stop if $P=\Lambda$. GET return,rJ \hfil$1$& %%% T3 SET t,Avail \hfil$n$& \ul{\sl T3. $\hbox{\rm Stack}\Leftarrow P$.} BZ t,Overflow \hfil$n$& LDOU Avail,Avail,Link \hfil$n$& STOU P,t,INFO \hfil$n$& STOU S,t,Link \hfil$n$& SET S,t \hfil$n$& LDOU P,P,Left \hfil$n$& $P\is \.{Left}(P)$. BNZ P,T3 \hfil$n+2a$& To T3 if $P\ne\Lambda$. T4 LDOU P,S,INFO \hfil$n$& \ul{\sl T4. $P \Leftarrow\hbox{\rm Stack}$.} LDOU t,S,Link \hfil$n$& STOU Avail,S,Link \hfil$n$& SET Avail,S \hfil$n$& SET S,t \hfil$n$& T5 SET t+1,P \hfil$n$& \ul{\sl T5. Visit $P$.} PUSHGO t,Visit,0 \hfil$3n$& LDOU P,P,Right \hfil$n$& $P\is \.{Right}(P)$. PBNZ P,T3 \hfil$n+2a$& \ul{\sl T2. $P=\Lambda$?} PBNZ S,T4 \hfil$a+2$& Test if the stack is empty. %%% PUT rJ,return \hfil$1$& 1H POP 0,0 %%off