Can u please explain me the dryrun of the recursive call involved in tree building process so that i can get the better picture of it.
nod.children.add(child)---->how this line get executed after the recursive call?
Can u please explain me the dryrun of the recursive call involved in tree building process so that i can get the better picture of it.
nod.children.add(child)---->how this line get executed after the recursive call?
take example of a binary tree for a binary tree there are two childrean so we take left and right Node
but in generic tree u have to take an arraylist of Node so that u can accomdate its all child. 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.
u have to take input using a for loop for each node child
Got it.Thank you for your response.