Thread: Structures, pointers and AVL trees

  1. #1
    Registered User
    Join Date
    Jun 2002

    Unhappy Structures, pointers and AVL trees


    I've a structure which consists of two char parts and a pointer.
    struct ex_data
    char part1[13];
    char part2[2];
    } exdata, *exdata_prt;

    The pointer is then being passed into an avl tree. I've written a function to "surf" the tree printing out details of the two parts. But I cannot get it to work, I need accessing the avl tree and return the contents of the of the structure. Can anyone help with this problem?

    Many thanks.
    Mark Shatford.

  2. #2
    Join Date
    Aug 2001
    Groningen (NL)
    In your structure, you need to have pointers to the childs.

    typedef struct ex_data exdata;
    typedef struct ex_data *exdata_ptr;
    struct ex_data
        char part1 [13];
        char part2 [2];
        exdata_ptr left_child;
        exdata_ptr right_child;
    Traversing can be done as follows:

    /* assume tree_ptr points at some node */
    /* now let tree_ptr point to a child */
    if (next_child == LEFT_CHILD)
        tree_ptr = tree_ptr->left_child;
        tree_ptr = tree_ptr->right_child;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with AVL Tree Pointers
    By Bnchs in forum C Programming
    Replies: 4
    Last Post: 04-06-2008, 06:09 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM