AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Create Binary Tree From Preorder input

Ein Thema von sk.Silvia · begonnen am 20. Apr 2006 · letzter Beitrag vom 22. Apr 2006
Antwort Antwort
Benutzerbild von sk.Silvia
sk.Silvia

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

Re: Create Binary Tree From Preorder input

  Alt 22. Apr 2006, 13:37
wooow, thats great, youare so claver, thanks a million, i had to modify the code a little bit but without you i wouldnt have a chance

Delphi-Quellcode:
  procedure TBinTree.CreateInorder(aList :TField; aLeft, aRight : Integer; Var aRoot : TBinTree);
  var m:integer;
        begin
        if aLeft>=aRight then aRoot:=TBinTree.Create(aList[aLeft],nil,nil)
                         else
                            begin
                            m:=(aLeft+aRight) div 2;
                            aRoot:=TBinTree.Create(aList[m],nil,nil);

                            if m>aLeft then CreateInorder(aList, aLeft, m-1, aRoot.Left);
                            if m<aRight then CreateInorder(aList, m+1, aRight, aRoot.Right);
                            end;
        end;

Call In Prog ->
BinTree.CreateInorder(TreeInput,Low(TreeInput),High(TreeInput),BinTree);
So ok, this creates a tree from an Inorder input, but lets say we have two inputs Preorder and Postorder, how can i create an tree from them?

i have to use binary tree cause of uni...but thats abit overwork (not neccessary needed to know for school), but iam trying hard to be the best and to know smt. more to be one day so clever as you again thank you

Silvi
  Mit Zitat antworten Zitat
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz