Einzelnen Beitrag anzeigen

Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#7

Re: Build Heap And Heapsort Without Array

  Alt 12. Mai 2006, 15:28
so ok, i have this code :

Delphi-Quellcode:
  procedure TBinTree.BuildHeap;
      begin
      if not(Left=nil) then
        begin
        if Left.Value>Value then
          begin
          Exchange(Left,Self);
          BuildHeap;
          end;
        Left.BuildHeap;
        end;
      if not(Right=nil) then
        begin
        if Right.Value>Value then
          begin
          Exchange(Right,Self);
          BuildHeap;
          end;
        Right.BuildHeap;
        end;
      end;
it works fine, but only just with one bug, it exchanges bad the values by the tree root (it dont makes just one exchange, the rest of the tree is ok)

somebody has an idea how to fix it?
  Mit Zitat antworten Zitat