Parent nide value add

Sir in this you are adding child value in ArrayList but parent node data is not added in ArrayList!
can you elaborate on these things because I am getting confused that how we fetch the value of the root node when we need it

@saurabhananta It happens at the end of recursion.
for example:
this.data=data;
this.children=new arraylist();

this.data stores the value in the data variable.

HI @saurabhananta
each node of the tree contains two parameter one is the data and the other one is arraylist of children nodes.
so after adding children into the arraylist we assign value parent node in the data parameter.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.