0

Can anyone tell me some real-life applications of recursions????

(It would be beneficial for a lot of people like me)

17th Oct 2020, 11:26 AM
Sean Santhosh
Sean Santhosh - avatar
3 Antworten
+ 2
Imagine a box that contains a smaller version of itself. The outside box has a very intricate way in unlocking it. Now, knowing that the inside box is a smaller scale replica of the outside box, we can assume they open the same way. So instead of taking the time to devise a new strategy to open the smaller box, you first check if what whas in the first box IS in fact a smaller box, then reuse the same method that was used for the larger box! Now imagine you have a computer's workload. Let's call it, 100 boxes within slighly larger versions of the same box. What recursion would do is use the same process to open all the boxes from the outside in at once (to the naked eye). This is just an example, please just look through code, write code yourself, or just look this up online.
17th Oct 2020, 12:01 PM
Slick
Slick - avatar
+ 2
Recursion is used in expression and statement parsing for compilers/interpreters.
17th Oct 2020, 5:09 PM
Brian
Brian - avatar
+ 1
Calculating a factorial with recursion def fact(n): if n == 1: return n else: return n*fact(n-1) https://code.sololearn.com/c2z4KiOAhVKA
17th Oct 2020, 12:14 PM
David Ashton
David Ashton - avatar