. 150, 152, .. .

:

 

P -

Q -

V - ,

T - , V

S - , V

 

 

()

 

Q=nil

P=Tree

While (P<>nil)and(K(P)<>key)do { }

If key<K(P) then P=Left(P)

Else P=Right(P)

EndIf

EndWhile

If P=nil then " " { }

Return {}

EndIf

If Left(P)=nil then V=Right(P) { nil

Else

If Right(P)=nil then V=Left(P)

Else

GetNode(P)

T=P

V=Right(P) S = Left(V)

While S <> nil { }

 

T = V { -}

V = S { }

S = Left(V)

EndWhile

If T <> P then

"V- "

Left(T) = Right(V)

Right(V)= Right(P)

EndIf

Left(V) = Left(P)

If Q = nil then

"p - "

Tree = V

Return

EndIf

If P = Left(Q) then

Left(Q) = V

Else

Right(Q)= V

EndIf

EndIf

EndIf

FreeNode(P)

Return

150, ( ).

 

 

 

 




- -  - -  - -