Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 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.                 sp=top(cp)
  31.                 if(ct->sx!=null) then
  32.                     cl=ret
  33.                     if(cp=0) then
  34.                         cld=top(sld)
  35.                         cx->next=cld
  36.                    
  37.                 else
  38.                     cld=ret
  39.                     cl=null
  40.                     if(cp=0) then
  41.                         cx=NEW-NODE(ct->k)
  42.                         cld=top(sld)
  43.                         cx->next=cld
  44.                    
  45.                 ret=cl         
  46.                 next=null
  47.                 pop(di tutto)
  48.         last=ct
  49.         ct=next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement