I need to dynamically add child nodes to a particular branch of a tree, according to the structure passed to me. For example, I have a structure like this :
struct my_struct
{
int a;
int b;
char c;
}
In my function, after moving to the node required, I should be able to add child nodes to the particular node, something like this :
root
|
son------daughter----another_son
|
a---b--c
My tree Node structure is as below :
struct tree{
string name;
int child_count;
int value;
vector< tree* > child;
};
Since I want to update each of these variables later, I want separate out the nodes for each variable in the structure. Since the structure can be updated without my knowledge, I want the logic to be structure independent.