Solution Review: Length of a String
Understand how to determine a string's length recursively by testing an empty string as the base case and reducing the string step-by-step. This lesson helps you break down the problem, implement the recursive function, and visualize the process to strengthen your recursion skills with strings.
We'll cover the following...
We'll cover the following...
Solution: Using Recursion
Explanation
The base case for this solution will test for an empty string "". If the string is empty we return .
For the recursive case, we call another instance of the same function, but we remove the first element. When the child element returns the length, we add to the returned length.
The recursive case is based on the paradigm that the length of the complete string is ...