Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub

Discussion in 'C Programming' started by sharan, Oct 30, 2007.

  1. sharan

    sharan Guest

    Hello Friends I have a problem in Data Structure (In C) i want to
    implement a General tree having three child nodes of each parent
    node ...please send me any simple Example( code) by which i can
    understand General Tree codes.....node be int value if possible than
    help me for a name(string)
     
    sharan, Oct 30, 2007
    #1
    1. Advertising

  2. sharan said:

    > Hello Friends I have a problem in Data Structure (In C) i want to
    > implement a General tree having three child nodes of each parent
    > node ...please send me any simple Example( code) by which i can
    > understand General Tree codes.....node be int value if possible than
    > help me for a name(string)


    See K&R2 pp139-142 to see how to build a tree using two child nodes, and
    then make the obvious change for three nodes. (At this point, of course,
    it will no longer be a binary search tree, so you'll need to decide how
    you're going to track down nodes within the tree.)

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Oct 30, 2007
    #2
    1. Advertising

  3. On Oct 30, 12:38 pm, sharan <> wrote:
    > Hello Friends I have a problem in Data Structure (In C) i want to
    > implement a General tree having three child nodes of each parent
    > node ...please send me any simple Example( code) by which i can
    > understand General Tree codes.....node be int value if possible than
    > help me for a name(string)



    firs of all you need to understand how to build the abstract tree data
    structure(if you still don't know it):
    http://en.wikipedia.org/wiki/Tree_(data_structure) (read theory,
    then walk throw the different trees implementations description, each
    article should contain at leas one link to particular tree sources).

    here for example avl tree sources. i think if you understand how it
    works, you can easily make needful changes:
    http://en.wikipedia.org/wiki/Tree_(data_structure)

    Dan Kruchinin
    W.B.R.
     
    Dan Kruchinin, Oct 30, 2007
    #3
  4. Dan Kruchinin, Oct 30, 2007
    #4
  5. sharan

    CBFalconer Guest

    Re: Hi, I want to implement a General Tree Data structure (Not BinaryTree ) which have more than 2 sub nodes?

    sharan wrote:
    >
    > Hello Friends I have a problem in Data Structure (In C) i want to
    > implement a General tree having three child nodes of each parent
    > node ...please send me any simple Example( code) by which i can
    > understand General Tree codes.....node be int value if possible
    > than help me for a name(string)


    struct node {
    struct node *left, *middle, *right; /* children */
    char *data; /* or whatever type you need */
    }

    Go from there.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    CBFalconer, Oct 30, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page