AP® Computer Science A glossary

Base case

Also called: stopping case

Course: AP® Computer Science A Shows up in: Unit 4: Data Collections

The condition in a recursive method where it returns without calling itself again, which halts the recursion.

Appears in the course and exam description (CED): 4.16.A.1

Every recursive method needs at least one base case, and each recursive call must move closer to it. If the base case is never reached, the calls never stop and the program ends with a StackOverflowError.

Example

if (n == 0)
{
    return 1;   // base case: no recursive call
}
Learn it properly, with a checkpoint 4.16 Recursion

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure