Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
In my opinion recursion has an advantage over looping when the we need to store a large amount of data in each cycle (that is one loop).
In looping one would need to store this data in new variables each time whereas recursion provides a more elegant way of doing so by employing stacks.
recursion can be usefull in algorithms like backtracking and dynamic programming algorithms ...but before making use of recursion make sure tht ur program terminates after some condition fails r else it may end up in stack overflow and the system may hang up....
Recursion is efficient in terms of logic less time comsumption of programming but are more memory consuming as memory acess are usally slow so make it slow in terms of run time
loops are difficult to programme but are more efficient as we are not using one function again and again and are using counters
For some applications recursive algorithm is much more simpler then corresponding looping algorithm, for example if you want to access the elements of singly linked link list in reverse order.
Also many mathematical algorithms can be implements in more natural way using recursive algorithm i.e. your implementation will look exactly same as mathematical definition of that algorithm, for example factorial and Fibonacci.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.