Nested lists are the best way to model something like a tree.   The 
title of your message talks about binary trees.  So, for example, you 
could use a structure where each node contains three elements, [left, 
data, right].  Here is a simple example (off the top of my head), 
assume a tree like this:

       1
    5   9

could be represented like this:

   [[VOID,1, VOID], 5, [VOID, 9, VOID]]

or a little deeper nesting:

                4
           2        6
         1  3    5

as:

  [[[VOID, 1, VOID], 2, [VOID, 3, VOID]], 4, [[VOID, 5, VOID], 6, VOID]]]

(I hope I got all the brakets right - but it should give you the basic idea)

You could certainly write a routine to create the tree data 
structure, then you could write recursive routines to search the tree.


If you use this approach, then the question you need to consider is, 
what data do you need to represent at each of your nodes.   If the 
"thing" at each node is just a single piece of data (as I've shown 
here), then just put the data there.  But if the "thing"  at each 
node is an object,  then you can place the object reference (the 
thing that you get back when you create an object), into the data 
portion.

Hope that give you a jump start.

Irv

At 12:51 PM -0500 10/5/01, Morales, Carlos R. wrote:
>I need to model a tree in Lingo.  I'm leaning towards modeling each node as
>an object and using the address of each the objects as I would pointers in
>C++.  Is this the best approach? 
>
>-carlos
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to