To define recursion is a method where the solution to a complex problem depends on solutions to smaller instances of the same problem. In any recursive problem, it is really important to figure out what constitutes the end of my process. Learn more about recursion in this tutorial.
- [Female Instructor] Before we take a look…at some programs, let's talk about the definition…of recursion in relation to programming.…Did you know that if you type the word recursion…in a Google search window, it will prompt you…with a message that says "did you mean recursion"?…Same spelling and everything.…I think Google's a little confused.…But actually it's meant to be a humorous answer…to the question of what is recursion.…In programming terms recursion…is when a method calls itself.…Another way to define recursion…is a method where the solution…to a complex problem depends on solutions to smaller,…more simpler instances of the same problem.…
In any recursive problem it's really important…to first figure out what constitutes the end of my process.…How do I know when I'm done?…This is called the base case.…Without it we would have an infinite process…because the method would constantly call itself with no end.…Once we define the base case the second part…is the recursive case,…where the function is defined in terms of itself.…
Programmers involved in mathematical computations, such as mathematical induction, are probably the biggest users of recursion. You probably know some of the most common recursive problems; finding the factorial of a number and the Fibonacci series are both examples of recursive processes. In this course, staff instructor and Java expert Peggy Fisher explores programming solutions involving both of these problems. She reviews the concept of recursion, discusses approaches to solving problems using recursion, and examines some recursive examples.
- Defining recursion
- Reviewing recursive examples
- Converting decimal to binary
- Printing a LinkedList
- Writing a power function