Whether to go for recurcide or iterative

these type of questions can be solved using both recurcise and iterative or bfs approach.
in recurcise code to be written is also less and is somewhat easy to implement but the iterative one requires more code writing and some thinking.

so when these type of questions come to us then which approach to prefer.

hello @Parmeet-Kalsi-1631789033630118

recursive code is easy to implement and r very less error prone .

whereass iterative code are not easy to implement and chances of commiting error is more.
so u can prefer recursion but do practice iterative approach as well becuase in interviews interviewr can explitcity ask u to implement using itertive.

Ok thanks for that,
But if the number of iterations or recurcise calls are of the order of 10 raised to power 9 ,
Then we should still to the recursive one only or go for iterative ones.

if ur iterative approach demands space same as recursion stack then go for recursive .
otherwise if iterative takes less or no space then go for iterative approach,

This thing is only when the constraints are large, else if contraints are in limit then always go with recursive one.
Is this conclusion fine

yeah u can say that.
keep practicing , and try to derive time and space complexity of every problem.
soon u will start realising when to use iterative and when to use recursion.

i missed one thing-> iterative appraoch is always faster than recursive approach becaue recursive approach involves function call (which consumes some time).
and this is not the case with iterative approach