O'Reilly logo

Advanced Topics in Java: Core Concepts in Data Structures by Noel Kalicharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 5

image

Recursion

In this chapter, we will explain the following:

  • What a recursive definition is
  • How to write recursive functions in Java
  • How to convert from decimal to binary
  • How to print a linked list in reverse order
  • How to solve Towers of Hanoi
  • How to write an efficient power function
  • How to sort using merge sort
  • How to use recursion to keep track of pending subproblems
  • How to implement backtracking using recursion by finding a path through a maze

5.1 Recursive Definition

A recursive definition is one that is defined in terms of itself. Perhaps the most common example is the factorial function. The factorial of a non-negative integer, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required