I have been looking trough stack, all the c++ books I can find online, cplusplus forum and I cannot find one implementation of "general tree".
Could someone help me understand what a general tree is. I can find quite a bit of info on AVL, nth-child trees, Red Black Trees etc, but I cannot find any clear information about general trees.
Could someone offer a simple example?
Pesudo code?
A general overview?
A chapter in a book to read?
ANY online examples?
Links to any information?
Please let me know if you have any specific questions for me. I do not want people to do work for me, I just need to understand the concept though a simple implementation and example
For instance...
Here is some info I found on stack, that looks like the way I want to go, but I am still not making the connection.
http://stackoverflow.com/questions/26102323/how-do-i-use-doubly-pointer-in-c-for-general-tree-data-structure
and the upvoted post
For general tree data structure you can use :-
1 2 3 4 5
|
struct tree{
int element;
struct tree *firstchild;
struct tree *nextsibling;
};
|
lement contains the data to be inserted at the node.
FirstChild contains the firstchild of the node.
nextsibling contains the other child of the same parent node. Example :-
then
1 2 3 4 5 6 7
|
A->firstchild = B;
B->nextsibling=C;
C->nextsibling=D;
B->firstchild=E;
E->nextsibling=F;
C->firstchild=g;
D->firstchild=H;
|
Other values which are not specified can taken as NULL;
|
The above makes sense from a conceptional point of view but I am not seeing the picture about how to implement it. Any advise or info would be appreciated.
EDIT 0:
I found
http://www.rsbauer.com/class/dsa2/slides/General%20Trees.pdf
General trees are similar to binary trees, except
that there is no restriction on the number of
children that any node may have.
|
So how would you take a binary tree and modify it? Is that the problem I need to solve?
EDIT 1:
This looks promising...
http://web.eecs.utk.edu/~mclennan/Classes/102/thinkCScpp/chap21.htm