Recursion tree for the question

can you please send the fully explained recursion tree for the above problem.Even after identifying base cases I am stuck with the dry run recursion tree.

Hey @Sachita3 I would request you to share picture of your dry run so that I can find out where you are getting troubled at. Will be happy to help you :grinning:

I wanted to know that how this recursion tree is also helping me visualising the combinations that I have made


Hey @Sachita3 , I hope this will help you visualising how recursion is working and calculating your answer. Moreover,I am sorry for my handwriting as it’s not as good as yours :grinning:
I hope I helped you :grinning: keep coding :+1:

Thanks but one thing as i am taking i = 0 in the beginning in my code(I am assuming that last digit is zero and still i am getting 5 ways for n = 3 how?).How should I pass both 1 and 0 as last digit should call it two times, one with 1 as last digit and second as 0 as last digit?

See if you are taking 0 as a last digit (one you have explained using brackets) you need not have to assume that second last digit is 0 or 1 cause it doesn’t matter because if last digit is 0 you can either place 0 in second last pos or 1 in second last pos As question is no consecutive 1. No need of thinking about second last position, and yes you have to call last index 2 times one with 0 and one with 1.

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.