University of Arizona, Department of Computer Science

CSc 120: List Palindrome (Recursive)

Expected Behavior

Write a recursive function palindrome_list(arglist), where arglist is a list, that returns True if and only if arglist is a palindrome, i.e., is the same sequence of elements whether it is traversed forwards from the first element or backwards from the last element.

Programming Requirements

Solve this problem using recursion. You are allowed to use only the following programming constructs:

Solutions that go outside these constructs, e.g., by using for/while loops or list comprehensions, will not get credit.

Examples

  1. palindrome_list(['aa','bb','bb','aa'])
    return value: True

  2. palindrome_list(['aa','bb','','bb','','aa'])
    return value: False

  3. palindrome_list(['aa','bb','aa',''])
    return value: False

  4. palindrome_list([])
    return value: True

  5. palindrome_list([1,2,3,2,1])
    return value: True

  6. palindrome_list([1,2,3,2])
    return value: False

  7. palindrome_list([[1,2],[3,4,3],[1,2]])
    return value: True

  8. palindrome_list([[1,2],[3,4,3],[2,1]])
    return value: False