CSCA08H3 Lecture 8: Week 8 Notes
Document Summary
Csc108h1f 2014: algorithm 3: can compare pairs of characters (last and rst character, second and second. If both halves are equivalent, it is a palindrome. If an odd number of character, you ignore the middle character (eg. e" in racecar"). last character, etc). If all the same, it is a palindrome. Again, if odd, you can ignore the middle character: the examples, type contract, header, and description were created (in that order) as shown to the right, note: the body and testing will be done in subsequent parts. Reminder: algorithm 1 uses the approach of comparing the reversed string to the original string to establish if it is a palindrome. Unlike lists, there is no reverse method or function for strings so we must create one: this function must reverse, for example, hello" to. Now we can create the function that checks if a string is a palindrome.