Course Home | Class Schedule | Assignments | Git Submission | Perusall | Python | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2018

Computer Science Department

Homework Assignment 17

Recursion

Overview

Topic: Recursion
Related Reading: Chapters 26 and 27
Due: 10:00am, Friday, 7 December 2018

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


Problems to be Submitted (20 points)

  1. (10 points)

    The chapter provides an implementation of OurList.index that accepts a single value as a parameter, with the public syntax data.index(val) responsible for returning the index of the first occurrences of the given value on the list (presuming it is found).

    The index method of the built-in list class accepts an additional optional parameter that is an index at which the search for the value should begin, as in data.index(val, k)

    Provide a new implementation of the OurList.index that includes such an optional parameter (with the default value of 0). You may assume that the parameter is a nonnegative integer.

  2. (10 points)

    Our implementation of the function search(lexicon, target) (Figure 27.4) was written to return a boolean result designating whether the target was contained in the list. Rewrite that function (and the corresponding _search utility) so that it returns the index at which the target is found in the list, when the search is successful, and the index at which the target would lie if inserted into the sorted list.


Michael Goldwasser
CSCI 1300/5001, Fall 2018
Last modified: Wednesday, 05 December 2018
Course Home | Class Schedule | Assignments | Git Submission | Perusall | Python | Tutoring