CMSC 201

Homework 8 - Due 4/16

This homework must be submitted by 8pm on the due date to get any credit.

For this homework, you must use recursion for every exercise.

  1. Write a recursive function called reverse that takes a list as an argument and reverses it.
  2. Write a recursive function called search that takes a list that is already in order and a single integer and returns the index at which that integer appears in the list. If the integer does not appear in the list, return -1.
  3. Write a function called stars that takes a single argument, height, and prints a triangle of stars of that height.
  4. Write a function called gcd that takes two arguments and finds the greatest common divisor between the two.

When you've finished your homework, use the submit command to submit the file. You must be logged into your account and you must be in the same directory as the file you're trying to submit. At the Linux prompt, type

submit cs201 HW8

After entering the submit command shown above, you should get a confirmation that submit worked correctly:


If not, check your spelling and that you have included each of the required parts and try again.

You can check your submission by entering:

submitls cs201 HW8

You should see the name of the file that you just submitted, in this case v