go to previous page   go to home page   go to next page

Answer:

The length of the tail of the string is:

1 + length( all but the first character of the tail )

Recursive Definition of String Length

Keep doing this until there are no characters in the tail. The tail of a string that contains one character is the empty string.

The length of a string is:

  1. If a string has no characters, then its length is 0.
  2. Otherwise,
    • the length of the string is 1 + length of the tail

This looks a lot like the "crossing the parking lot" procedure in chapter 90.


QUESTION 4:

Does the "string length" definition have the two parts of recursion?


go to previous page   go to home page   go to next page