We introduced recursion in Chapter 6 and showed how to write recursive methods
to implement mathematical functions. We used mathematical functions in
Chapter 6 because it is easier to see how the recursion works with mathematical
functions. However, recursive methods are not limited to implementing mathematical
functions, and we will present several nonnumerical recursive algorithms in
this chapter. We will also discuss some criteria for deciding when to use recursion
and when not to. All the recursive algorithms we provide in this chapter, other than
those we use for explanation, are algorithms that should be written recursively.
O b j e c t i v e s
After you have read and studied this chapter, you should be able to
Write recursive algorithms for mathematical
functions and nonnumerical operations.
Decide when to use recursion and when not to.
Describe the recursive quicksort algorithm and
explain how its performance is better than that
of selection and bubble sort algorithms.
To learn more about the book this website supports, please visit its Information Center.