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

Saint Louis University

Computer Science 1300
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2017

Computer Science Department

Homework Assignment 12

Recursion

Contents:


Overview

Topic: Recursion
Related Reading: Chapter 11
Due: 11:00am, Friday, 8 December 2017

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


Problems to be Submitted (18 points)

  1. (6 points)

    Exercise 11.9 of the text
    Note: This question is asking specifically about OurList.__le__.

  2. (6 points)

    Exercise 11.10 of the text

  3. (6 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 1300, Fall 2017
Last modified: Thursday, 28 April 2011
Course Home | Assignments | Computing Resources | Lab Hours/Tutoring | Python | Schedule | Submit