⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽

Recursion

Computer Programming C++ / Functions

My favorite definition of recursion is, "A recursive function is a function that calls itself, until it doesn't." That probably doesn't make a lot of sense, so let's jump right in and program one.

Let's look at another (more practical?) example. In the next two videos we'll write code to check if a word (or phrase) is a palindrome. Before we get to the palindrome function though, we'll need to write a helper function.

If you've forgotten what a palindrome is, it's a word or a phrase who's characters are the same forewards as they are backwards. For example: "kayak," "nurses run," and "no lemon, no melon," are all palindromes.

Review Questions

The following are examples of questions similar to what you can expect to see on the next exam.

Hover over a question to show the answer.
  1. What is a recursive function? A function that calls itself, until it doesn't.
⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽
© Ryan Appel