Java Reference
In-Depth Information
Chapter
12
Introduction
12.1
Thinking Recursively
A Nonprogramming Example
This chapter focuses on a programming technique known as recursion that
allows us to solve certain complex problems in a highly elegant manner.
The chapter begins by comparing recursion with the problem-solving
techniques you already know.Then it discusses the low-level mechanics
that make recursion work in Java. Finally, we examine a number of prob-
lems that are easily expressed using this technique.
An Iterative Solution Converted
to Recursion
Structure of Recursive Solutions
12.2
A Better Example of
Recursion
Mechanics of Recursion
12.3
Recursive Functions and
Data
Recursion turns out to have a surprising range of useful applications,
including recursive graphics that are known as fractals. But programming
recursively also requires some special techniques that we'll have to
explore. Recursive programming also requires a different mind-set in gen-
eral, so the chapter explores a large set of example problems to reinforce
this new way of thinking.
Integer Exponentiation
Greatest Common Divisor
Directory Crawler
Helper Methods
12.4
Recursive Graphics
12.5
Case Study: Prefix
Evaluator
Infix, Prefix, and Postfix
Notation
Evaluating Prefix Expressions
Complete Program
718
Search WWH ::
Custom Search