Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo(T,k,P){
- St, Sp, Sir, Sh1, ret=-1;
- next, currT=T, currP=P, ir = 0;
- while(St != Nil or currT!=Nil){
- if ir = 0 then
- ret = -1
- if currT != Nil then
- push(St,currT)
- push(Sp,currp)
- push(Sir,0)
- next = currT->sx
- currP = currT
- ir=0
- else
- ir=top(Sir)
- pop(Sir)
- next = top(St)
- currP = top(Sp)
- if ir==0 then
- ir=1
- push(Sir,1)
- else if ir == 1 then
- ir=2
- push(Sir,2)
- else if ir == 1 then
- push(Sh1, ret)
- next = currT->dx
- currP= currT
- ir=0
- pop(Sir)
- push(Sir,1)
- else if ir == 2 then
- h2 = top(Sh1) + ret
- pop(Sh1)
- ret = h2+1
- if ret > k and currP!= Nil then
- if currT == currP->Dx then
- currP->Dx = CANCELLA_RADICE(currT)
- else
- currP->Sx = CANCELLA_RADICE(currT)
- pop(St)
- pop(Sp)
- pop(Sir)
- ir=Top(Sir)
- next=Top(St)
- currP = Top(Sp)
- if(ir == 0) then
- ir = 1
- else if (ir == 1) then
- ir = 2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement