I want to build a tree with the following characteristics:
- Every node can have 1 "next node".
- Every node can have multiple child nodes.
- The number of child nodes can vary from one node to the other
I was thinking of a struct which looked like this:
struct tree {
int value;
struct tree* nextnode;
struct tree** childnode;
};
The number of children at each node has to be parametrized. I am not sure how to do this. Thanks in advance!
Edit: Let me try to define it using an example: Let us take the starting node. Now, I will define at compile time that there will be 3 NextNodes and each of these NextNodes will have 2 ChildNodes. This is at Depth=0. At Depth = 1 (i.e. for each child node from Depth=0) I specify that there will be 4 NextNodes and for each of these NextNodes there will be 3 ChildNodes and so on. Hope I am able to convey it properly. Please do ask if I am not clear somewhere.
Edit2: Here is a pic:
