0

If I have to do the basic tree with these declarations

    typedef struct item
    {
        char petname[20];
        char petkind[20];
    } Item;

    typedef struct node
    {
        Item item;
        struct node * left;    /* pointer to right branch  */
        struct node * right;   /* pointer to left branch   */
    } Node;

    typedef struct tree
    {
        Node * root;           /* pointer to root of tree  */
        int size;              /* number of items in tree  */
    } Tree;

what changes do I need to solve this

*Modify the Pet Club program so that all pets with the same name are stored in a list in the same node. When the user chooses to find a pet, the program should request the pet name and then list all pets (along with their kinds) having that name.
*

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by zeroliken
0

how would you insert a node in the tree given a pet name?
Is choosing if to move to the left and right child alphabetical by the name of the pet?

as my opinion on knowing the root you could simply make a pointer for the first node of the tree, and use that pointer as the root to traverse the whole tree
also the petname and petkind variables can go in the node structure to make assigning more easier
To summarize you could simply use one structure for the whole program to make it simpler

Edited by zeroliken: added info

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.