Skip to content

Recursion: base case and recursive case · ⁨递归:基本情形与递归情形⁩

English

A method that calls itself

  • Recursion is when a method calls itself to solve a smaller piece of the same problem.
  • On the AP CSA exam you mostly trace recursion (follow the calls by hand). Writing small recursive methods helps you trace well.
  • Every recursive method needs two parts: a base case and a recursive case.
中文

一个调用自己的方法

  • 递归(recursion)就是一个方法调用它自己,来解决同一个问题的更小一块。
  • 在 AP CSA 考试中,你主要是追踪递归(用手跟着一步步走)。会写一些小的递归方法能帮你追踪得更好。
  • 每个递归方法都需要两个部分:一个基本情形(base case)和一个递归情形(recursive case)。

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩