You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a parent-children structure, so that whenever a cranbtree is cloned, its clone is attached to it. As a consquence, whenever a parent is to be deleted, all it's children will be deleted as well and their roots is set to NULL.
Design
Add a parent field to the struct cranbtree that will be set to the parent if the tree is a clone. Set to NULL if the tree is not a clone.
Add a list of clones to struct cranbtree that will contain a list of pointers to the clones of the parent.
Algorithm
Whenever a clone is created:
set the parent field of the clone to the parent that it was cloned from
Add a pointer to the clone to the list of children of the parent.
Whenever the clone is deleted:
Go to the parent before the deletion and remove the pointer of this clone from the list
note: remember destroy_objects function does not get applied to objects stored in a clone
Whenever a parent is deleted:
set the root pointer of the children to NULL
Destroy the children
Destroy the parent
The text was updated successfully, but these errors were encountered:
Task
Create a parent-children structure, so that whenever a cranbtree is cloned, its clone is attached to it. As a consquence, whenever a parent is to be deleted, all it's children will be deleted as well and their roots is set to NULL.
Design
Algorithm
Whenever a clone is created:
Whenever the clone is deleted:
note: remember destroy_objects function does not get applied to objects stored in a clone
Whenever a parent is deleted:
The text was updated successfully, but these errors were encountered: