CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Guest

    tree data structure

    Is there any source code which implements tree data structure? I mean something like "CTree" as CArray for array or CList for linked list in MFC. I also hope that it is not restricted to binary trees, but able to handle general trees with varying degree (number of child nodes).


  2. #2
    Join Date
    May 1999
    Location
    13 N 77 E
    Posts
    183

    Re: tree data structure

    Try STL


  3. #3
    Guest

    Re: tree data structure

    Thanks.
    But I couldn't find out in STL any suitable template container class for tree data structure. What do you suggest in STL specifically? In general one can implement tree data structure using linked lists, but I want more direct method.


  4. #4
    Join Date
    May 1999
    Location
    13 N 77 E
    Posts
    183

    Re: tree data structure

    You seem to be right and I am surprised.
    I vaguely remember some C header file named btree.h. I am sure someone must have implemented an AVL tree library and made it publicly accessible. If not it would be nice if you worked on it and made it available ..If that is too hard maybe you could use a hidden tree control !
    good luck



  5. #5
    Join Date
    Jun 1999
    Posts
    3

    Re: tree data structure

    Did you ever come up with anything...
    I'm confronted with the same problem had hoped something
    was already available...


  6. #6
    Join Date
    May 1999
    Posts
    69

    general tree data structure

    Lets discuss properties
    (I have to implement one anyway...)

    I need
    - fast child lookup
    - fast insertion/deletion of child nodes
    - detection of equivalent paths (potential tree)
    - different amount of memory in every node
    - mark of a main variation


    chrislaw

  7. #7
    Join Date
    Jun 1999
    Posts
    3

    Re: general tree data structure

    Well, my requirements are not very demanding.
    I need something to store Registry data. I was
    thinking along the lines of something derived from
    CTree (if found) that I could tailor to Registry
    information (CRegTree). The access methods would
    be similar to the API Registry routines (path
    oriented).
    FYI, this is for a client/server Registry engine.


  8. #8
    Join Date
    May 1999
    Location
    13 N 77 E
    Posts
    183

    Re: general tree data structure

    There seems to be some BTree source for C++ on the simtel site

    http://oak.oakland.edu/simtel.net

    I havent seen the code..



  9. #9
    Guest

    Re: tree data structure

    I think a linked list is the best implementation for a Tree-structure.
    I cannot provide code, but maybe you are interested in a class the extends
    the CTreeCtrl to multiple selection of items:

    http://www.techsoft.no/bendik/





  10. #10
    Join Date
    Jun 1999
    Posts
    3

    Re: general tree data structure

    BTree's are great for sorted data...
    (Binary Tree, each node has two branches, etc)
    But that's not what I'm looking for.

    Plus...I just got moved to another project,
    but I will still be glad to help anyway I can.


  11. #11
    Join Date
    May 1999
    Location
    13 N 77 E
    Posts
    183

    Re: general tree data structure

    A BTree is not merely a binary tree but also sorts data and uses the AVL algorithm for optimized height balancing for quick retrieval.

    Check Knuth, but he probably uses the term AVL trees. A mere binary tree is quite trivial anyway.


  12. #12
    Join Date
    May 1999
    Posts
    123

    Re: tree data structure

    The map and multimap classes in STL are typically implemented as red/black trees. Depending on what you're tyring to accomplish, this may or may not be useful.

    I've also written a binary tree class that's somewhat similar, though it makes no attempt at balancing itself, so if it gets out of balance, the performace can suck.

    Depending on exactly what you're trying to accomplish, it may also be extremely trivial to implement your own -- it sounds like you want direct control over the tree's structure rather than having it attempt to keep itself balanced (which doesn't normally apply to multiway trees) which tends to be the easiest thing to implement.


    The universe is a figment of its own imagination.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured