Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALGOIT(T,k,P)
- ST=STP=STH1=LAST=NIL
- CT=T
- while(ct!=NIL || st!=NIL)do
- if(ct!=NIL)then
- ret=-1
- st=push(st,ct)
- stp=push(stp,cp)
- CP=CT
- ct=ct->sx
- else
- ct=top(st); cp=top(stp)
- if(last!=ct->dx && ct->dx!=NIL)then
- h1=val
- sth1=push(sth1,h1)
- ct=ct->dx
- else
- if(ct->dx=NIL)then
- h1=val
- h2=h1-1
- ret=h2+1
- if(ret > k ^ cp!=NIL)then
- if(ct=cp->dx)then
- cp->dx=cancellaroot(ct)
- else
- cp->sx=cancellaroot(ct)
- +uscita algoritmo
- else
- top(sth1); pop(sth1)
- h2=h1+val
- ret=h2+1
- if(ret > k ^ cp!=NIL)then
- if(ct=cp->dx)then
- cp->dx=cancellaroot(ct)
- else
- cp->sx=cancellaroot(ct)
- +uscita algoritmo
- return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement