Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo(T,x,y)
- curr=T last=null next=null
- Stack S=null Sy=null Sx=null Svol=null Sa=null
- while(curr!=null OR S!=null)do
- if curr!=null then
- a=1
- b=1
- val=curr->key
- Push(Sval,val)
- if x <= val <= y then
- next=curr->sx
- Push(S,curr)
- Push(Sy,y)
- y=val-1
- else
- next=null
- a=0
- else
- curr=Top(S)
- y=Top(Sy)
- val=Top(Sval)
- if curr->dx != null AND curr->dx != last then
- next=curr->dx
- a=ret
- if a != 0 then
- Push(Sa,a)
- Push(Sx,x)
- x=val+1
- else
- if curr->dx != null then
- b=ret
- else
- b=1
- a=Top(Sa)
- x=Top(Sx)
- ret=a && b
- Pop(S, Sa, Sy, Sx, Sval)
- last=curr
- curr=next
- return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement