tree data structure - ???pointers in VB???

M

Martin Mrazek

Hello,

can anybody advise how to represent a general tree data structure in
VB(A)? (In Pascal o C it would be typical type of problem solved by
pointers). For example I have something like the following:

Elements of data structure: a1, a2, a3, ..., aENDm (value of ENDm is
arbitrary).
Properties of each element:
P1. Each element has one double value
P2. Each element has zero, one or two successors
P3. Each element, except the first one, has just one predecessor
P4. Each element can show to its successors – on the "Sample of data
structure" bellow: a5.successor(1) = a8, a5.successor(2) = a7 etc.

It means if elements are considered as objects:

Object element
--------------
a5.value = 3.45 (type double)
a5.successor(1) = a8 (??type?? pointer)
a5.successor(2) = a7
....
a3.successor(1) = nothing


Sample of data structure
------------------------
a1 --> a2 --> a9 ... aEND1
|--> a3
|--> a4--> a5 --> a8 ... aEND2
.. | |--> a7 ... aEND3
.. . .
.. . .
.. . .
.. .
.. '--> aENDn
..
‘--> aENDm

Numbers END1, ..., ENDn,..., ENDm differs dramatically according to
user of my VB application (I emphasize that from user to user also the
number of structure ending elements (m in above example) differs).

I feel there should be some solution using OOP for that, but
unfortunately, I'm beginner in OOP. Can you advise, please?

Martin
 
T

Tushar Mehta

This looks like a homework assignment. If not, state so, and I'll be
happy to share more information.

Use a class module. Just remember that you can declare an object
declared in the class module that is of the same class, i.e., a class
named Tree can have: Dim x as Tree

--
Regards,

Tushar Mehta
MS MVP Excel 2000-2004
www.tushar-mehta.com
Excel, PowerPoint, and VBA tutorials and add-ins
Custom Productivity Solutions leveraging MS Office
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top