1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46:
| type PBinBaum = ^TKnoten; TKnoten = record Inhalt: Integer; links,rechts:PBinBaum; end; procedure insert(var baum:PBinBaum; elem: Integer); begin if (baum = nil) then begin baum := new(PBinBaum); baum.inhalt:=elem; baum.links := nil; baum.rechts:= nil; end else if elem>baum.inhalt then insert(baum.rechts,elem) else if elem<baum.inhalt then insert(baum.links,elem); end; procedure max_vergl(baum:PBinBaum; var max,links,rechts:integer); var llinks:integer; lrechts:integer; begin llinks:=links; lrechts:=rechts; if Baum<>nil then begin if Baum.links<>nil then begin llinks:=llinks+lrechts; max_vergl(baum.links,max,llinks,rechts); end; if Baum.rechts<>nil then begin lrechts:=lrechts+llinks; max_vergl(baum.rechts,max,llinks,lrechts); end; end; if links>max then max:=links else max:=rechts; end; |