Entry
Delphi: Datastructure: Tree: Binary: Create: Simple: How to create a binary tree in Delphi?
Oct 28th, 2003 23:01
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 29 October 2003 - 05:44 am --------------------
Delphi: Datastructure: Tree: Binary: Create: Simple: How to create a
binary tree in Delphi?
---
Here is shown a simple definition of an empty binary tree.
---
program MyTreeCreateExample;
{$APPTYPE CONSOLE}
type
treeP = ^treeR;
treeR = record
leftpointerP : treeP;
mydataS : string;
rightpointerP : treeP;
end;
begin
end.
---
It will define a node structure like the following:
[left pointer - mydata - right pointer]
---
---
Here an example of the use of this binary tree.
---
program MyTreeCreateExample;
{$APPTYPE CONSOLE}
type
treeP = ^treeR;
treeR = record
leftpointerP : treeP;
mydataS : string;
rightpointerP : treeP;
end;
var mytreeR : treeR;
begin
mytreeR.leftpointerP := nil;
mytreeR.mydataS := 'some info to store in this tree';
mytreeR.rightpointerP := nil;
//
writeln( 'the current content of the data in this tree is ' +
mytreeR.mydataS );
end.
---
If you compile this source code, it will show:
---
+---------------------------------------------------------------------+
|> dcc32.exe -Ic:\progra~1\borland\delphi7\lib |
| -Rc:\progra~1\borland\delphi7\lib |
| -cc -q -v -h -w MyTreeCreateExample.pas |
| |
|Borland Delphi Version 15.0 |
|Copyright (c) 1983,2002 Borland Software Corporation |
|25 lines, 0.07 seconds, 11048 bytes code, 1813 bytes data. |
| |
|> MyTreeCreateExample.exe |
| |
|the current content of the data in this tree is some info to store in|
|this tree |
| |
|Press any key to continue . . .
+---------------------------------------------------------------------+
---
---
Book: see also:
---
[book: see also: author: Horowitz, Ellis / Sahni, Sartaj - p. 212 -
'binary tree representations' - title: fundamentals of datastructures
in Pascal - publisher: Computer Science Press - year: 1987 - ISBN 0-
88175-165-0]
---
---
Internet: see also:
---
BBCBASIC: Datastructure: Tree: Binary: Create: Simple: How to create a
binary tree in BBCBASIC?
http://www.faqts.com/knowledge_base/view.phtml/aid/26122/fid/768
---
C#: Datastructure: Tree: Binary: Create: Simple: How to create a
binary tree in C#?
http://www.faqts.com/knowledge_base/view.phtml/aid/26116/fid/791
---
C++: Datastructure: Tree: Binary: Create: Simple: How to create a
binary tree in C++?
http://www.faqts.com/knowledge_base/view.phtml/aid/25923/fid/163
---
Java: Datastructure: Tree: Binary: Create: Simple: How to create a
binary tree in Java?
http://www.faqts.com/knowledge_base/view.phtml/aid/26106/fid/165
----------------------------------------------------------------------