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

Saint Louis University

Computer Science 150
Introduction to Object-Oriented Programming

Michael Goldwasser

Spring 2013

Dept. of Math & Computer Science

Homework Assignment 10

Recursion

Contents:


Overview

Topic: Recursion
Related Reading: Chapter 11
Due: 1:10pm, Wednesday 1 May 2013

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
    Note: This question is asking specifically about OurList.__le__.

  2. (5 points)

    Exercise 11.10 of the text

  3. (5 points)

    Exercise 11.23 of the text

  4. (5 points)

    Exercise 11.24 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 2013
Last modified: Thursday, 28 April 2011
Course Home | Assignments | Computing Resources | Lab Hours/Tutoring | Python | Schedule | Submit