How does recursion really works in computer science?

195 views

How does recursion really works in computer science?

In: 0

5 Answers

Anonymous 0 Comments

Recursion just means something that calls itself.

Here’s an example: List all the files in all subfolders of a directory.

Your code outline might look something like this:

Function: parseFolder

Logic: List all files in the folder. Then, for each subfolder of this folder, call parseFolder.

Practically, what this is going to do is list all the files in each folder, go into the subfolders of that folder and list those files, go into the subfolders of *that* folder and list all the folders, etc, until there are no more subfolders to explore.

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