How does recursion really works in computer science?

197 views

How does recursion really works in computer science?

In: 0

5 Answers

Anonymous 0 Comments

Depends on the language you are using but most operate the same way.

Functions take up space in the ram to operate so each function has it’s own dedicated space. When you call a function it creates that space for the function to inhabit. When a function calls itself, it creates another space in the ram for the this function to inhabit. This continues until (hopefully) a base case returns (where the space is unreserved and can be used for more stuff). Otherwise it’ll keep on creating new space on the ram for functions until you quite literally run out, although modern cpus will just kill the program before that happens.

This explanation is of course wildly oversimplified but the concept is like that.

You are viewing 1 out of 5 answers, click here to view all answers.