Einzelnen Beitrag anzeigen

xaromz

Registriert seit: 18. Mär 2005
1.682 Beiträge
 
Delphi 2006 Enterprise
 
#6

Re: Thats Insane - wrong memory setting by recursion???

  Alt 20. Apr 2006, 20:36
Hello,

one problem (but not the only one I guess) with your code is that you haven't set the Result prior to comparing it to "Value". So "Result" is undefined.
I think you were trying to do something like this:
Delphi-Quellcode:
function TBinTree.FindMin: Integer;
begin
  Result := Value; // Assume current Value is lowest

  if Assigned(Left) then
    Result := Min(Left.FindMin, Result); // Get lowest value [current, left]

  if Assigned(Right) then
    Result := Min(Right.FindMin, Result); // Get lowest value [current, right]
end;
xaromz
  Mit Zitat antworten Zitat