algo(T,x,y)
a=1;
b=1;
if(T!=0)then
val=T-->k
if x<=val<=y then
a=algo(T,x,val-1)
if a !=0 then
b=algo(T,val+1,y)
else
a=0
ret= a&&b
return ret
Io l'ho svolto in questo modo:
Algo_IT(T,X,Y)
currX=x
currY=y
stackX=nill
stackY=nill
stackVal=nill
currT=t
last=nill
a,b;
nextX=nill
nextY=nill
While(curry!=nill||stackT!=nill)di
if(curry!=nill)then
a=1;
b=1;
val= cura-->K
if(x<=val<=y)then
stackX=push(stackX.currX)
stackY=push(stackY.currY)
stackVal=push(stackVal.Val)
nextT=T-->sx
y=val-1
else
currX=top(Stack X)
currY=top(Stack Y)
currVal=top(StackVal)
if(T-->sx!=0 && T--->dx!=0)then
a=ret
if(a!=0)then
stackX=push(stackX.currX)
stackY=push(stackY.currY)
stackVal=push(stackVal.Val)
nextT=T-->ds
y=val-1
else
currX=top(Stack X)
currY=top(Stack Y)
currVal=top(StackVal)
b=ret
ret=a&&b
last=curr
curr=next
return ret
penso che non vada bene