Course Home | Assignments | Class Photo | Computing Resources | Lab Hours/Tutoring | Schedule | Submit

Saint Louis University

Computer Science 150
Introduction to Object-Oriented Programming

Michael Goldwasser

Spring 2010

Dept. of Math & Computer Science

Homework Assignment 11

Recursion

Contents:


Overview

Topic: Recursion
Related Reading: Chapter 11
Due: 9:00am, Friday 23 April 2010

Please make sure you adhere to the policies on academic integrity.


Problems to be Submitted (20 points)

  1. (5 points)

    Exercise 11.9 of the text

  2. (5 points)

    Exercise 11.10 of the text

  3. (5 points)

    Exercise 11.24 of the text

  4. (5 points)

    Exercise 11.29 of the text


Extra Credit

  1. (2 points)

    Recall that the syntax data[i:j] returns a new list which is a slice of the original list, starting with the element at index i and going up to but not including the element at index j. Behind the scene, that is supported by the __getitem__ method, with the parameter appearing as a special instance of a class named slice.

    However, there is deprecated support, from older versions of Python, allowing you to override the slicing behavior by implementing a special method with signature __getslice__(self, i, j).

    Provide a recursive implementation of __getslice__(self, i, j) for use within the OurList class. Keep in mind that this method should return a new instance of OurList (as opposed to the standard list class). You may assume that integers i and j are nonnegative.

    Remember that the original list should not be mutated when computing a slice, or subseuqently modifying that computed slice.


Michael Goldwasser
CSCI 150, Spring 2010
Last modified: Friday, 16 April 2010
Course Home | Assignments | Class Photo | Computing Resources | Lab Hours/Tutoring | Schedule | Submit