there is a loop inside display function every time display functon is recursively called then each time the 2nd loop will intiate from i=0; then for every i=0; again function display is called how it’s going to end
please explain .
2nd loop condition
hi @dheerajmishra992
for each node you have to print all the children of that node that why we are using 2nd loop inside display function
no I am just asking after which statement the value of i will reach i=1 in the second for loop
@dheerajmishra992
let suppose you have a tree like this
. 1
/ \ \
2 3 4
for node 1
first it will print children of 1
then in second loop we get i=0 th child of 1 which is 2
then we print children of 2 which are none in this case.
then call will return to second for loop and the we get i=1 th child of 1 which is 3 in this case
and the process continues.
if you still have doubt you can inbox me.
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.