Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition
by Paul J. Deitel - Deitel & Associates, Inc., Harvey M. Deitel - Deitel & Associates, Inc.
7.19. Recursion
It is sometimes useful for methods to call themselves—a recursive method is a method that calls itself either directly or indirectly (i.e., through another method). In this section, we present a simple example of recursion.
Let us first consider recursion conceptually. Recursive problem-solving approaches have a number of elements in common. A recursive method is called to solve a problem. The method actually knows how to solve only the simplest case(s)—the base case(s). If the method is called with a base case, it returns a result. If the method is called with a more complex problem, it divides the problem into two conceptual pieces—a piece that the method knows how to perform (i.e., base case), and a piece that it does not know ...
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.
Read now
Unlock full access