Binary Tree 
Author Message
 Binary Tree

Does anyone know where I can get some simple code to create a binary tree
structure in Pascal? Thanks in advance.

--

Listen to my tunes!
http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 Binary Tree
im in the same boat :o)

craig


Quote:
> Does anyone know where I can get some simple code to create a binary tree
> structure in PASCAL? Thanks in advance.

> --

> Listen to my tunes!
> http://www.mp3.com/rawlyn



Wed, 18 Jun 1902 08:00:00 GMT  
 Binary Tree

Quote:
> im in the same boat :o)
> > Does anyone know where I can get some simple code to create a binary tree
> > structure in PASCAL? Thanks in advance.

   This may help both of you:

program BINARY_TREE;      { Binary Tree with Pointers Example }
const EOD = -98765;                       { End-of-Data value }
type BTT  = ^NODE;                      { define pointer type }
     NODE = record                   { template for tree node }
       NUM    : integer;                         { node value }
       LP, RP : BTT                                { pointers }
     end;
var  CURR : integer;                    { current input value }
     TREE : BTT;                           { pointer variable }
     MORE : boolean;                     { input data control }
procedure INSERT (var WORK : BTT);{ insert value(s) into tree }
                             { This procedure is Recursive... }
var  NEWP : BTT;                      { local working pointer }
begin
  if WORK = Nil then
    begin                          { insert element into tree }
      New (NEWP);               { obtain new pointer location }
      with NEWP^ do
        begin
          NUM := CURR;                { add value to new node }
          LP  := Nil;        { set new node pointers to "Nil" }
          RP  := Nil; RP  := Nil
        end;
      WORK := NEWP                { move local node into tree }
    end
  else   if CURR < WORK^.NUM then      { belongs on left side }
           INSERT (WORK^.LP)              { walk left node(s) }
         else                         { belongs on right side }
           INSERT (WORK^.RP)             { walk right node(s) }
end;                                           { of procedure }
procedure PRINTTREE (FILLED : BTT);         { print tree data }
begin
  if FILLED <> nil then                   { process some data }
    begin
      PRINTTREE (FILLED^.LP);          { process left node(s) }
      write (FILLED^.NUM:5);   { write out current node value }
      PRINTTREE (FILLED^.RP)          { process right node(s) }
    end
end;                                           { of procedure }
begin                                             { Main Line }
  MORE := true; TREE := Nil;                     { initialize }
  writeln ('Enter random integers; terminate with -98765');
  while MORE do
    begin                             { read data & load tree }
      read (CURR);                        { read a data value }
      if CURR = EOD then MORE := false          { end of data }
      else INSERT (TREE)                       { process data }
    end;                                           { of while }
  writeln ('Sorted input numbers:');                { heading }
  PRINTTREE (TREE);                  { walk & print tree data }
  writeln; writeln ('Finis...')
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 Binary Tree

Quote:

>im in the same boat :o)

>craig



>> Does anyone know where I can get some simple code to create a binary tree
>> structure in PASCAL? Thanks in advance.

>> --

>> Listen to my tunes!
>> http://www.mp3.com/rawlyn

I'll look into it!

This binary tree:
 For what purpose do you want 2 use it?
 E-mail me than I'll help you!
Cause I find this one off the more sensefull quaetions!

Heinrich



Wed, 18 Jun 1902 08:00:00 GMT  
 Binary Tree

Quote:


>>im in the same boat :o)

>>craig



>>> Does anyone know where I can get some simple code to create a binary
tree
>>> structure in PASCAL? Thanks in advance.

>>> --

>>> Listen to my tunes!
>>> http://www.mp3.com/rawlyn

>I'll look into it!

>This binary tree:
> For what purpose do you want 2 use it?
> E-mail me than I'll help you!
>Cause I find this one off the more sensefull quaetions!

>Heinrich

Hi there!

I've looked into it and my tutoriul now inclueds a part to teach trees!
Go download it at my web-site:

In the tutoriul it's under pointers!

homes.arealcity.com/heinrichshomepage/

See I keep my promises!

Heinrich



Wed, 18 Jun 1902 08:00:00 GMT  
 Binary Tree
Hi,


Quote:
> homes.arealcity.com/heinrichshomepage/

Despite the fact that you are constantly plugging it, your homepage "doesn't
work", that is, I always get 404 File Not Found.

 - Sebastian

--
This posting was manufactured to meet critical quality standards.
If you believe the posting has a manufacturing defect, please call our
Quality Management Department at ++49-800-BASTISOFT.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. The use of coprcessor reals (previously Re: Stack overflow at binary tree balance)

2. Stack overflow at binary tree balance

3. Binary tree problem

4. How to determine the height of a binary tree

5. Recursion and Binary Tree

6. Recursion and Binary Tree

7. Binary tree proof.

8. Showing Binary trees

9. Binary-Tree

10. binary tree question

11. Binary Trees

12. binary tree/dictionary

 

 
Powered by phpBB® Forum Software