Homework 4,
Five Recursive Pieces.
Short Description:
Recursive Programs.
This assignment is worth 100 points.
Goals
When you finish this homework, you should:
- Design and implement simple recursive algorithms.
- Work with static 2 dimensional arrays.
Formal Description
Implement the following programs.
- multiply
- palindrome
- binaryConversion
- numberReverse
- maze
Multiply
Write a program which will display a multiplication table for up to 12×12.
Input
None
Output
The table.
Discussion
All multiplications for the table must be done using a recursive function.
Mult(m,n)
if (n =1)
Mult(m,n) = m
else
Mult(m,n) = m + Mult(m,n-1)
Palindrome
Write a program which will determine if a string is a palindrome. For this program, we will ignore non
letter characters, as well as punctuation, space and capitalization.
Able was I ere I saw elba. is a palindrome.
Live devil, lived evil! is a palindrome.
race car #4 is a palindrome.
This program should be interactive, and continue until the user types in the
string QUIT
Input/Output
Example Session: (Computer output in bold)
Enter a string or QUIT: Able was I ere I saw elba.
Able was I ere I saw elba. is a palindrome
Enter a string or QUIT: Mad dame!
Mad dame! is not a palindrome.
Enter a stbing or QUIT: QUIT
Good By!
Discussion
The code should include a recursive routine which takes a string and returns
true if the string is a palindrome and false if it is not. This routine
must include a call to a recursive routine. However the routine in's self might just preprocess the string.
BinaryConversion
Write a program that implements problem 2 page 1008 of your book.
Discussion
You should have a recursive function that takes in integer and returns
a string containing the binary representation of the input integer.
Number Reverse
Write an interactive program which reads in a number, and prints out
the corresponding number with reversed digits.
Input/Output
The program should be interactive, and should continue until a -1 is entered.
Enter a number: 1234
The reverse of 1234 is 4321
Enter a number: -1
Good By
Discussion
This program should employ a recursive routine to reverse the digits of the
number.
Maze
Implement a solution to program 6, page 1009 of the book.
Input
Your program should prompt the user for the name of a file containing a maze.
Output
Your program should output two lists, one that indicates all points from which
one can escape the maze and the other indicating points from which one can not
escape the maze.
Discussion
This program is not trivial, but it is not impossible either. You should not
start on it until we discuss two dimensional arrays.
Required Files
The source code, ReadMe, and Makefile for all programs should
be submitted in a single tar file.
Submission
Email the tar file to dbennett@edinboro.edu no later than class time November 5.