Recursion

From Computer Science Wiki
Revision as of 15:24, 6 March 2018 by Mr. MacKenty (talk | contribs)
Programming basics[1]

Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem (as opposed to iteration). The approach can be applied to many types of problems, and recursion is one of the central ideas of computer science [2]

A simple definition: Recursion is the process of a subroutine calling itself.

Example[edit]

<syntaxhighlight lang=python> def factorial(n):

   if n == 1:
       return 1
   else:
       return n * factorial(n-1)

</syntaxhighlight

Recursion[edit]

Another look at recursion[edit]


Standards[edit]

  • Identify a situation that requires the use of recursive thinking.
  • Identify recursive thinking in a specified problem solution.
  • Trace a recursive algorithm to express a solution to a problem.

See Also[edit]

References[edit]