Why has recursion been used in this?

so the time complexity is O(l*2^n) actually for the iterative one

.

yes. time complexity of printing subsequence is l * 2^n.
and l will be n only

no, I think this l is not for printing subsequence. it is for checking the bitmasking sequence.

yes , it is for checking bitmasking sequnece.
and u need to check n bit positions thats why it will be N.

check the inner loop and u willl get what i m saying

yes, got it. the iterative one has O(n*2^n) time complexity without counting printing of subsequences.

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.