Skip to content

Lab 17: CodingBat Recursion

For this lab, we will complete exercises from CodingBat.com to learn how to solve problems using recursion.

Learning Objectives

After completing this lab, you should be able to:

  • Describe the steps of recursive problem-solving.
  • Solve recursive problems using a helper method.
  • Implement recursive methods in Java.

Login to CodingBat

Make sure you log in to CodingBat for your submissions to be counted. Grading will be done directly from CodingBat. If you have still not set up your CodingBat account, please see the Lab02 instructions.

Warm-Up Problems (2pts)

First, let's brush up on your recursion writing skills!

Solve the following problems (spend no more than a few minutes on each):

  1. factorial
  2. bunnyEars
  3. fibonacci

Advanced Recursion (4pts)

The following problems involve recursion with strings. You may want to review the Java String methods first.

  1. countHi
  2. changeXY

Challenging Problems (4pts)

These problems work with arrays, and will help you develop the skills needed to tackle the homework.

For these problems, it is required that you write a second, "helper" method that performs the recursion, and then call it to start the recursive process.

  1. array11
  2. combinify

Extra Problems (optional)

If you finish early, complete these problems for practice:

  1. count11
  2. tenTimes