Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes? (http://www.velocityreviews.com/forums/t548028-hi-i-want-to-implement-a-general-tree-data-structure-not-binary-tree-which-have-more-than-2-sub-nodes.html)

sharan 10-30-2007 09:38 AM

Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes?
 
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 10-30-2007 10:01 AM

Re: Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes?
 
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

Dan Kruchinin 10-30-2007 11:39 AM

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.com> 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_%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 10-30-2007 11:52 AM

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
> 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 10-30-2007 08:21 PM

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



All times are GMT. The time now is 05:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.