Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo(T,a,b)
- St,Sir
- currT = T
- Ir=0
- ret = Nil
- while(St != Nil or currT != Nil)
- if ir == 0 then
- if currT != nil then
- push(St,currT)
- if currT->key < a then
- currT = currT->Sx
- push(Sir, 1)
- else if currT->key > b then
- currT = currT->Dx
- push(Sir, 2)
- else
- currT = currT->Sx
- push(Sir, 3)
- else
- ret = currT
- ir = Top(sir)
- pop(Sir)
- currT = Top(St)
- pop(St)
- else if ir == 1 then
- currT->sx = ret
- ret = currT
- ir = Top(sir)
- pop(Sir)
- currT = Top(St)
- pop(St)
- else if ir == 2 then
- currT->dx = ret
- ret = currT
- ir = Top(sir)
- pop(Sir)
- currT = Top(St)
- pop(St)
- else if ir == 3 then
- currT->sx = ret
- push(St, currT)
- currT = currT->dx
- push(Sir,4)
- ir = 0
- else if ir == 4 then
- currT->dx = ret
- currT = CANCELLA_RADICE(currT)
- ret = currT
- ir = Top(sir)
- pop(Sir)
- currT = Top(St)
- pop(St)
- return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement