top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Do we have any standard way to convert a recursive C function to iterative C function?

+1 vote
420 views
Do we have any standard way to convert a recursive C function to iterative C function?
posted Sep 2, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

See first understand recursion and iteration is a method/approach of solving a problem, so to solve a problem you can follow iterative way or recursive way which ever is suitable for you.

In iteration we give importance to Initial value and condition till which it will iterate while in case of recursion you will see Base case (When to stop recurring).

So i feel it's all about ur logic of solving the problem, If you want convert a iterative solution to recursive solution

So think about ur base case/s [When to stop] then you can easily convert it to recursive approach.

But to give you a note recursive needs more space as we are creating multiple stack frames each time we call the same function.

answer Sep 2, 2015 by Sachidananda Sahu
Similar Questions
+5 votes

Say I have a function which is written in recursive way which is costly way of doing the things. Now I want to convert the recursive function into iterative one. Is there a standard approach which can be applied to all the functions..

...