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

Answer:

By applying the same procedure to the tails


Recursive Definition of Equals

Here are the details of string equality, written as a recursive definition. Say that the two strings are StringA and StringB.

  1. If StringA has no characters and StringB has no characters, then the strings ARE equal.
  2. If StringA has no characters and StringB has some characters, then the strings are NOT equal.
  3. If StringA has some characters and StringB has no characters, then the strings are NOT equal.
  4. Otherwise,
    • if the first character of StringA is different from the first character of StringB, then the strings are NOT equal.
    • if the first character of StringA is the same the first character of StringB, then the strings are equal if the tails ARE equal.

QUESTION 17:

Does every character of both strings need to be examined to determine equality?

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