Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algo_IT(T,P,x)
- ST=STA=STP=LAST=NIL
- CT=T ; CP = P;
- while(CT != NIL || ST != NIL) do
- if(CT != NIL) then
- ret = 0
- ST = push(ST,CT)
- STP = push(STP, CP)
- CT = CT->SX
- P = CT
- else //risalgo dalla prima chiamata ricorsiva riga 3
- CT = TOP (ST) ; CP = TOP(STP) ;
- if ( LAST =! CT->DX && CT->DX != NIL ) then
- a = val;
- STA = push(STA, A)
- CT=CT->DX
- P=CT
- else
- if (LAST = CT->DX) then
- b=val
- TOP(STA); POP(STA);
- ret = a+b+1
- else
- a=val
- b=0
- ret=a+b+1
- if(CT->Key%2 = 0 ^ ret < x ^ P != NIL) then
- if(CT=CP->DX)then
- CP->DX=cancella_radice(CT)
- else
- CP->SX=cancella_radice(CT)
- Pop(ST);Pop(STP);
- LAST = CT;
- CT = NIL;
- return ret;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement