Recursive structures

  • Recursive structures:

    • Recursive structures are structures that contain a smaller version of itself

    Example: this triangle is made up with 3 triangles that is identical to itself

Problems that have a recursive nature

  • Some problems have a recursive nature:

      • To solve the (orginal) problem, you end up solving one or more smaller problems

      • Each of the smaller problem have the same description as the (original) problem

  • Illustration:   imagine that each doll represents a problem

    Solving the (original) problem requires us to solve one or more smaller problem(s)

Recursion: recursive method

  • Recursive method:

    • A recusive method is a method that invokes itself.

  • This technique is called recursion:

    • Recursion is a powerful programming technique to solve problems that have a recursive nature

  • In some cases, recursion enables you to write a very simple solution to solve an otherwise difficult problem.

  • This chapter introduces the concepts and techniques of recursive programming and illustrates with examples of how to "think recursively".