Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. AlgoIT(T,a,b)
  2.     ct=-1 st=null
  3.     next=last=null
  4.     ret=null
  5.     while(ct!=null && st!=null) then
  6.         if(ct!=null) then
  7.             if(ct->key<b) then
  8.                 st=push(ct,st)
  9.                 next=ct->dx
  10.             else
  11.                 st=push(st)
  12.                 next=ct->sx
  13.         else
  14.             ct=top(st)
  15.             if(ct->dx!=null && ct->dx!=last) then
  16.                 ct->sx=ret
  17.                 if(ct->key<a) then
  18.                     ret=ct
  19.                 else
  20.                     next=ct->dx
  21.             else
  22.                 if(ct->dx!=null) then
  23.                     if(ct->key>b) then
  24.                         ct->dx=ret
  25.                         ret=ct
  26.                     else
  27.                         ct->dx=ret
  28.                         ct=F(ct)
  29.                         ret=ct
  30.                 else
  31.                     if(ct->key>b) then
  32.                         ct->dx=null
  33.                         ret=ct
  34.                         next=null
  35.                     else
  36.                         ct->dx=null
  37.                         ct=F(ct)
  38.                         ret=ct
  39.                     st=pop(st)
  40.                    
  41.         last=ct
  42.         ct=next
  43.                    
  44.     return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement