Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //STACK: T,x
- Dubbi: ri-pushare x nello stack dopo aver fatto x=a+x
- al rigo 6, quando ct->sx=NIL, y sarΓ uguale a 1?
- ALGO (T) {
- st,sx=NIL;
- ct=T;
- lt=NIL;
- ritorno=NIL
- WHILE (ct!=NIL || st!=NIL) DO
- IF (ct!=NIL) THEN
- ret=1;
- x=ct->key%2;
- st=PUSH(st,t);
- sx=PUSH(sx,x);
- ct=ct->dx;
- ELSE
- st=TOP(st);
- sx=TOP(sx);
- IF (lt=ct->dx) THEN
- a=ritorno;
- x=a+x;
- sx=POP(sx);
- sx=PUSH(sx,x);
- IF (ct->sx!=NIL) THEN
- ct=ct->sx;
- ELSE
- y=1;
- ret=x*y*ct->key;
- st=POP(st);
- sx=POP(sx);
- lt=ct;
- ct=NIL;
- ritorno=ret;
- ELSE //lt=ct->sx
- y=ritorno;
- ret=x*y*ct->key;
- st=POP(st);
- sx=POP(sx);
- lt=ct;
- ct=NIL;
- ritorno=ret;
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement