CS 151 -- Lab Oct 26

Write the following recursive programs:
  1. Use recursion to write a Java method for determining if a string s has more vowels than consonants. The words to be checked should come from the command line
  2. Given an unsorted array, A, of integers and an integer k, write a recursive algorithm for rearranging the elements in A so that all elements less than or equal to k come before any elements larger than k. What is the running time of your algorithm on an array of n values? The integer array to be so arranged can be hardcoded into the main function
  3. Write a recursive function that will allow you to answer the question What is the largest number of recursive function calls that Java allows? Also, does java stop recusion at the same place every time? Does Java stop recursion in the same place on every machine?
  4. Recursive functions are usually a single function which calls itself. Write a "recursive loop" of 3 methods such that the first calls the second, the second calls the third and the third calls the first. The number of times you go arround this loop should be controlled by a parameter that is passed arround the loop. The methods in the loop can be quite short (several could be as short as one line of code).
  5. Write a short recursive Java method that determines if a string s is a palindrome, that is, it is equal to its reverse. Examples of palindromes include 'racecar' and 'gohangasalamiimalasagnahog'. The string to be checked should come from the command line. Do not use loops or stacks to do this, only recursion. One approach: compare first and last letters; if they are the same, recur on a string from which you removed the first and last letters. For instance:
                String aa = "asdfdsa";
                System.out.println(aa.substring(1, aa.length()-1));        

What to hand in

Stop after 80 minutes (I do not expect you to complete all of these, I simply could not pick the ones I wanted to skip.) Send email containing the functions you completed to gtowell151@cs.brynmawr.edu.