AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Suchfunktion Ergebnis der Suchanfrage

Ergebnis der Suchanfrage


Datum des Suchindex: Heute, 21:02

Parameter dieser Suchanfrage:

Suche in Thema: Create Binary Tree From Preorder input
Suche alle Beiträge, die von "alzaimar" geschrieben wurden
• Suchmethode: "Suche nach allen Begriffen"
• Nach Datum (firstpost) sortiert
• Zeige Treffer als Beiträge
Zeige 3 von insges. 3 Treffern
Suche benötigte 0.005s

Es liegen Ergebnisse in folgenden Bereichen vor:

  • Forum: Object-Pascal / Delphi-Language

    Re: Create Binary Tree From Preorder input

      Delphi
      by alzaimar, 22. Apr 2006
    :gruebel: The mentioned algorithm constructs a perfectly balanced tree out of *any* list, no matter how it is sorted.
    If the list is sorted in ascending order, the resulting tree is exactly what you expect: The left part is always smaller than the root, the right side is larger.

    Now, if the list is sorted in descending order, but you want to remain the left-right order, you have to reverse...
  • Forum: Object-Pascal / Delphi-Language

    Re: Create Binary Tree From Preorder input

      Delphi
      by alzaimar, 22. Apr 2006
    What do you mean by 'two lists, one pre- the other one postorder' :gruebel: ?
    If Yo have the list in reversed order, simply reverse 'left' and 'right'.

    BTW: If you must deal with binary trees, ever tried AVL-Trees or Red-Black-Trees? They are self-balancing.
  • Forum: Object-Pascal / Delphi-Language

    Re: Create Binary Tree From Preorder input

      Delphi
      by alzaimar, 22. Apr 2006
    Hi,

    Try something like this:
    Divide the list into two halves. The mid element is your root.
    Now do a recursive call to create a tree out of the left sub list and return the root as the left child of the above mentioned root. Do the same with the right sub list.

    Procedure CreateTree (aList : TList; aLeft, aRight : Integer; Var aRoot : TNode);
    Begin
    If aLeft >= aRight Then
    aRoot...


URL zu dieser Suchanfrage:

https://www.delphipraxis.net/dp_search.php?do=usersearch&search_username=alzaimar&search_exact_username=1&search_sortby=dateline&search_resulttype=post&search_matchmode=0&searchthreadid=67826
Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz