The Line on Recursion

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.
go to previous page   go to home page   hear noise   go to next page

Answer:

Stop when there are 16 pieces.

The Line on Recursion

Recall the two parts of a recursive solution:

  1. If the problem is easy, solve it immediately.
  2. If the problem can't be solved immediately, divide it into smaller problems, then:
    • Solve the smaller problems.

In terms of the "divide a line into 16 pieces" problem these are:

  1. If a line is small enough, don't divide it.
  2. Divide the line into two pieces.
    • Apply this process to each of the two pieces.

QUESTION 9:

How many sides does a snowflake have?