I agree (or if I am under 13 my parent or guardian agrees on my behalf) to the terms and conditions of use and that: - My test statistics may be published on the site leaderboard against my username - My teacher(s) can review my test scores - I can receive feedback on my tests from my teacher(s)
Computer Science & Programming solved. All in one platform.
1. To trial the platform and take tests, please take a few seconds to SIGN UP and SET UP FREE. 2. Searching for something specific? See our text overview of all tests. Scroll right for levels, and lists.
In computer science, recursion is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem. Such problems can generally be solved by iteration, but this needs to identify and index the smaller instances at programming time. Recursion solves such recursive problems by using functions that call themselves from within their own code.
Examples given in VB.Net - use as pseudocode and convert into your language of choice.
Suggested Video - Python and Recursion
Think of recursion like a magic superpower that allows you to solve problems easily!
The approach can be applied to many types of problems, and recursion is one of the central ideas of computer science.
"The power of recursion evidently lies in the possibility of defining an infinite set of objects by a finite statement. In the same manner, an infinite number of computations can be described by a finite recursive program, even if this program contains no explicit repetitions."
— Niklaus Wirth, Algorithms + Data Structures = Programs, 1976
Most computer programming languages support recursion by allowing a function to call itself from within its own code.