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

S

sharan

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)
 
R

Richard Heathfield

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.)
 
D

Dan Kruchinin

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.
 
C

CBFalconer

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)

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

Go from there.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top