Base Case

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

11 plus the number of pins in 10 rows.

Base Case

This keeps on going. Each round divides the problem into an integer and a problem that is smaller by one. Eventually you reach the end:

number of pins in 12 rows = 12 + number of pins in 11 rows
number of pins in 11 rows = 11 + number of pins in 10 rows

                        . . .

number of pins in  3 rows =  3 + number of pins in 2 rows
number of pins in  2 rows =  2 + number of pins in 1 row
                          =  2 + 1

The number of pins in 1 row is called a base case. A base case is a problem that can solved immediately. In this example, the number of pins in 1 row is 1.

QUESTION 5:

In the "destroy a rock" problem of the previous chapter, what was the base case?