Connecting Tech Pros Worldwide Forums | Help | Site Map

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

sharan
Guest
 
Posts: n/a
#1: Oct 30 '07
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)


Richard Heathfield
Guest
 
Posts: n/a
#2: Oct 30 '07

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


sharan said:
Quote:
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
Dan Kruchinin
Guest
 
Posts: n/a
#3: Oct 30 '07

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


On Oct 30, 12:38 pm, sharan <harioumsha...@gmail.comwrote:
Quote:
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_%28data_structure%29 (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_%28data_structure%29

Dan Kruchinin
W.B.R.

Dan Kruchinin
Guest
 
Posts: n/a
#4: Oct 30 '07

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


here for example avl tree sources. i think if you understand how it
Quote:
works, you can easily make needful changes:http://en.wikipedia.org/wiki/Tree_%28data_structure%29
sorry, it was invalid link. here is valid one:
http://src.opensolaris.org/source/xr...mmon/avl/avl.c

Dan Kruchinin
W.B.R.


CBFalconer
Guest
 
Posts: n/a
#5: Oct 30 '07

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


sharan wrote:
Quote:
>
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

Closed Thread