Given structure:
struct node {
int data;
struct node *next;
struct node *child;
};
How can I add elements in n-Ary tree level by level? The reason behind this is that I want to make my tree complete or nearly complete.
Could use any form of help, hint, suggestion.
User will input number n, which means that every node can have that many children, not greater than that. The problem is, I only know to add root and first n elements after. I am not sure how to get back to the first element after root, so that I can now put other nodes as his children and so on.
Root -> NULL
|
V
Child-1.1 -> Child-1.2 -> ... -> Child-1.n -> NULL
| | |
| V V
| ... Child-1.n.1 -> ... -> NULL
V
Child-1.1.1 -> Child-1.1.2 -> ... -> NULL
|
... etc
binaryTreeNode* temp = Q -> front -> data;work exactly? - Henk Holterman