3

I am building a tree data structure, in which I have an array of pointers in every node (node* children[FIXED_SIZE]), that point to children (size of the array is fixed):

I want to have a child inside the child variable (without freeing memory associated with it) but I also want to delete link between parent and children. Am I doing it correctly?

node* child = NULL;
i=2;
child = parent->children[i];
parent->children[i] = NULL;

1 Answer 1

2

Am I doing it correctly?

Assuming 2 is less then FIXED_SIZE, your code looks ok.


Referring your wording:

I want to have a child inside the child variable

child does not "have a child inside" but references, points to one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.