Course Home | Homework | Programming | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 180
Data Structures

Michael Goldwasser

Spring 2006

Dept. of Math & Computer Science

Homework Assignment 05

Recursion

Contents:


Overview

Topic: Recursion
Related Reading: Ch. 2.5.1, 4.1, 10.1.1, 10.3
Due: Tuesday, 28 March 2006, 1:10pm

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


Practice Problems


Problems to be Submitted (20 points)

  1. (6 points)

    Describe a recursive algorithm to compute the product of two positive integers, m and n, using only additions. (thus you should not use the binary * operator). Your code should have a signature:

          int Product(int m, int n);
          

  2. (7 points)

    Reinforcement Exercise R-4.6 of the text (page 196).

  3. (7 points)

    Ch 2.5.1 describes a recursive procedure drawTicks(int tickLength). For this problem, we are interested in determining the number of lines of output which are generated by a call drawTicks(L) for a given integer L, including all of the recursive calls it generates.

    1. As a function of L, how many lines of output are generated?
      (Hint: You might wish to try out a few small values by hand)

    2. Give a proof of your result!


Extra Credit

  1. (2 points)

    Creativitiy Exercise C-4.3 (page 197) of the text (though you need not discuss the running time).


Michael Goldwasser
CSCI 180, Spring 2006
Last modified: Saturday, 04 March 2006
Course Home | Homework | Programming | Schedule & Lecture Notes | Submit