Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. Algo(T,L)
  2.     ct=null st=null
  3.     cx=null sx=null
  4.     cp=null sp=null
  5.     cld=null sld=null
  6.     cl=null
  7.    
  8.     next=null
  9.     last=null
  10.     ret=null
  11.     while(ct!=null || st!=null) then
  12.         if(ct!=null) then
  13.             cp=ct->k%2
  14.             sp=push(cp,sp)
  15.             st=push(ct,st)
  16.             next=ct->dx
  17.         else
  18.             ct=top(st)
  19.             if(ct->sx!=null && ct->sx!=last) then
  20.                 cld=ret
  21.                 if(cp=0)then
  22.                     cx=NEW-NODE(ct->k)
  23.                     sx=push(cx,sx)
  24.                     sld=push(cld,sld)
  25.                     cl=cx
  26.                 else
  27.                     cl=cld
  28.                 next=ct->sx
  29.             else
  30.                 if(ct->sx!=null) then
  31.                     cl=ret
  32.                     if(cp=0) then
  33.                         cld=top(sld)
  34.                         cx->next=cld
  35.                    
  36.                 else
  37.                     cld=ret
  38.                     cl=null
  39.                     if(cp=0) then
  40.                         cx=NEW-NODE(ct->k)
  41.                         cld=top(sld)
  42.                         cx->next=cld
  43.                    
  44.                 ret=cl         
  45.                 next=null
  46.                 pop(di tutto)
  47.         last=ct
  48.         ct=next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement