Trees

This is a discussion on Trees within the Windows Programming forums, part of the Platform Specific Boards category; I need some help with trees. I want to learn how to create trees. Is there any tutorials on this?...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    8

    Trees

    I need some help with trees. I want to learn how to create trees. Is there any tutorials on this?

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You need to get some seeds, dig a hole in the ground and the seeds in it. What? Oh, yeah you mean a different sort of tree, sorry my mistake

    Seriously, what type of tree are you meaning?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    76
    I would have thought this query was vague. Not trees that grow from the ground, but trees with nodes and directories.

    Assuming this, the most abstract tree I can think of has a root item with children (if it has any). Every item, including the root, should have a pointer to its first child item (if it has children), its last child item (if it has children), its parent, and the items that come after and before itself. Each item can have its own data structure such as the following:

    Code:
    typedef struct _treeitemstruct{
     struct _treeitemstruct * parent;
     struct _treeitemstruct * firstchild;
     struct _treeitemstruct * lastchild;
     struct _treeitemstruct * prev;
     struct _treeitemstruct * next;
    // add other data here
    }TREEITEMSTRUCT;
    You should probably find a way to link (and unlink) the items in this manner.

    You should call malloc to dynamically allocate the item structures, when necessary, so they can easily be freed just by traversing the tree from the root item (which also should be allocated).

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    8
    sorry about this. I meant a tree view control. Something that is used with files a lot, like in windows Explorer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trees
    By masterg in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2008, 01:42 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. Trees
    By samtay in forum C++ Programming
    Replies: 7
    Last Post: 03-28-2004, 09:35 AM
  4. Binary Trees...
    By SirCrono6 in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2003, 04:54 PM
  5. AVL Trees
    By kwigibo in forum C Programming
    Replies: 2
    Last Post: 04-17-2002, 06:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21