thats insane, try to run this...you will get the most highest parent (node 0) as result, but try to run it with ShowMessage('val '+ValToStr+' res'+inttostr(result)); and you will get the right result...also you get the right result by adding result:=result;
but WHY?????????????????????????????????????
OMG WHY???????????????????
Delphi-Quellcode:
type TBinTree=class
Value:integer;
Left,Right: TBinTree;
...
function FindMin(init:boolean):integer;
end;
function TBinTree.FindMin(init:boolean):integer;
begin
//ShowMessage('val '+ValToStr+' res'+inttostr(result));
//result:=result;
if value<result then
begin
result:=value;
end;
if init then result:=self.Value;
if not(left=nil) then result:=left.FindMin(false);
if not(right=nil) then result:=right.FindMin(false);
end;
in prog -> ShowMessage(IntToStr(BinTree.MindMin(true)));
HOW CAN SHOWMESSAGE CHANGE THE RESULT OF A RECURSION????? AND WHY HAVE RESULT:=RESULT; THE SAME EFFECT??