Skip to Content
Java Illuminated, 5th Edition
book

Java Illuminated, 5th Edition

by Julie Anderson, Hervé J. Franceschi
January 2018
Intermediate to advanced content levelIntermediate to advanced
1204 pages
28h 27m
English
Jones & Bartlett Learning
Content preview from Java Illuminated, 5th Edition

13.1 Simple Recursion: Identifying the General and Base Cases

When designing a recursive solution for a problem, we need to do two things:

  • define the base case

  • define the rule for the general case

For example, if we want to print “Hello World” 100 times, we can do the following:

  • print “Hello World” once

  • print “Hello World” 99 times

Note that we do two things: First, we print “Hello World” once, which is easy to do. Then we reduce the size of the remaining problem to printing “Hello World” 99 times. In order to print “Hello World” 99 times, we print “Hello World” once, then we print “Hello World” 98 times. Continuing the same approach, to print “Hello World” 98 times, we print “Hello World” once, then we print “Hello World” 97 times, and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Illuminated, 3rd Edition

Java Illuminated, 3rd Edition

Julie Anderson, Hervé J. Franceschi
Java How To Program, Late Objects, 11th Edition

Java How To Program, Late Objects, 11th Edition

Paul J. Deitel, Harvey M. Deitel

Publisher Resources

ISBN: 9781284141092