i have to create a program which can have n number of nodes and each subnode can have n number of subnodes and so on, its not a binary tree. i need to know how can one create it?
+2
A:
You are looking for n-ary trees - http://oopweb.com/Algorithms/Documents/PLDS210/Volume/n_ary_trees.html The creation should be pretty simple from the information in this and other links (in google).
Koran
2010-06-13 10:50:39
A:
Instead of having something like this:
Node* left;
Node* right;
which you would normally do for a binary tree, you can do something like:
Node** children;
int size;
then malloc
the appropriate size for the number of pointers.
Jon Skeet
2010-06-13 10:52:03
@allthanks for the helpi developed a code for n number of nodes with hepl of ur info
samurai_01
2010-06-15 11:29:03
A:
GLib provides an implementation of N-ary trees. If you can't use glib you should look for another library that suits your needs or roll your own N-ary tree. In a simple version a node would contain a linked list or array with pointers to further nodes.
pmr
2010-06-13 10:52:18